uses crt;
const s:array[1..7] of char=('I','V','X','L','C','D','M');
var
n:integer;
st:string;
begin
repeat
begin
write('vvesti chislo ');
readln(st);
if st=s[1]
then n:=1;
if st=s[2]
then n:=5;
if st=s[3]
then n:=10;
if st=s[4]
then n:=50;
if st=s[5]
then n:=100;
if st=s[6]
then n:=500;
if st=s[7]
then n:=1000;
writeln(n);
end
until st='.';
readln;
end.