using System;
public class Program
{
public static void Main()
var s = "IX";
Program p = new Program();
Console.WriteLine(p.RomanToInt(s));
}
public int RomanToInt(string s) {
int total = 0;
char prior = 'A';
foreach(var v in s)
switch(v)
case 'I':
total += 1;
break;
case 'V':
if(prior == 'I')
total += 4;
total -= 1;
else
total += 5;
case 'X':
total += 9;
total += 10;
case 'L':
if(prior == 'X')
total += 40;
total -= 10;
total += 50;
case 'C':
total += 90;
total += 100;
case 'D':
if(prior == 'C')
total += 400;
total -= 100;
total += 500;
case 'M':
total += 900;
total += 1000;
prior = v;
return total;