Var a1, b1: integer; a, b: char;
begin
read(a, b);
case a of
'i': a1 := 1;
'v': a1 := 5;
'x': a1 := 10;
'l': a1 := 50
end;
case b of
'i': b1 := 1;
'v': b1 := 5;
'x': b1 := 10;
'l': b1 := 50
end;
if a1 < b1
then
writeln(b1 - a1)
else
writeln(a1 + b1);
end.