#define T trim(copy(b,2*i+1,2)) var a:array[0..12]of word=(900,1000,400,500,90,100,40,50,9,10,4,5,1);s,b:string="CMM CDD XCC XLL IXX IVV I";i,n:word;begin repeat readln(s);n:=0;while s>""do for i:=0to 12do if pos(T,s)>0then begin n:=n+a[i];delete(s,pos(T,s),length(T))end;writeln(n)until 1=0end.