var s,p:string; n,i,m:integer; c,d,e,f:char; begin readln(s); n:=length(s); for i:=1 to n do begin if (s[n-1]='V') and (s[n]='I') then begin c:=s[n-1]; s[n-1]:=s[n];s[n]:=c;end; if (s[n-1]='X') and (s[n]='I') then begin c:=s[n-1]; s[n-1]:=s[n];s[n]:=c;end; if (s[i]='L') and (s[i+2]='X') and (s[i+1]<>'X') then begin c:=s[i]; s[i]:=s[i+2]; s[i+2]:=c;end; if (s[i]='X') and (s[i+1]='I') then begin c:=s[i]; s[i]:=s[i+1]; s[i+1]:=c;end; END; if s='LXIX' then s:='XLIX'; if s='XIL' then s:='LIX'; if s='XIL' then s:='XLI'; if s='LIXX' then s:='XLIX'; IF S='LIIX' then s:='XLII'; writeln(s); end.