type int = longint;

var
  s: string;
  s1: string;
  i, d, j, k: int;
  c: char;
//  p:array[0..10012] of int;
  pm,pd,pc,pl,px,pv,pi:int;  

begin

  while not eof do
  begin
    readln(s);
    s1 := "";
    d := length(s);
    for i:=1 to d do 
      begin
      c:=s[i];
      if (c='m') or (c='M') or (c='c') or (c='C') or (c='L') or (c='l') or (c='X') or (c='x') or (c='V') or (c='v') or (c='i') or (c='I') then
        s1:=s1+c; 
      end;
//    writeln(s1);  
    s:=s1;
    d:=length(s);
//    for i:=0 to d do
//      p[i]:=0;
    j:=0;
    s1:='';
    for i:=j+1 to d do
      begin
      if (s[i]='m') or (s[i]='M') then
        begin
        s1:=s1+'m';
	j:=i;
	end;
      end;  
    for i:=j+1 to d do
      begin
      if (s[i]='d') or (s[i]='D') then
        begin
        s1:=s1+'d';
	j:=i;
	end;
      end;  
    for i:=j+1 to d do
      begin
      if (s[i]='c') or (s[i]='C') then
        begin
        s1:=s1+'c';
	j:=i;
	end;
      end;  
    for i:=j+1 to d do
      begin
      if (s[i]='l') or (s[i]='L') then
        begin
        s1:=s1+'l';
	j:=i;
	end;
      end;  
      
    for i:=j+1 to d do
      begin
      if (s[i]='x') or (s[i]='X') then
        begin
        s1:=s1+'x';
	j:=i;
	end;
      end;  
      
    for i:=j+1 to d do
      begin
      if (s[i]='v') or (s[i]='V') then
        begin
        s1:=s1+'v';
	j:=i;
	end;
      end;  
    for i:=j+1 to d do
      begin
      if (s[i]='i') or (s[i]='I') then
        begin
        s1:=s1+'i';
	j:=i;
	end;
      end; 
    d:=length(s1);
    j:=0;
    k:=0;
    s:=s1;
    pm:=0;
    pd:=0;
    pc:=0;
    pl:=0;
    px:=0;
    pv:=0;
    pi:=0;
//    writeln(s);
    for i:=1 to d do
      begin
      if s[i]='m' then
        begin
	  j:=j+1000;
	inc(pm);
	end else
      if s[i]='d' then
        begin
	if pd<1 then 
	  j:=j+500;
	inc(pd);  
	end else
      if s[i]='c' then
        begin
	if pc<3 then 
	  j:=j+100;
	inc(pc);  
	end else
      if s[i]='l' then
        begin
	if pl<1 then 
	  j:=j+50;
	inc(pl);  
	end else
      if s[i]='x' then
        begin
	if px<3 then 
	  j:=j+10;
	inc(px);  
	end else
	
      if s[i]='v' then
        begin
	if pv<1 then 
	  j:=j+5;
	inc(pv);  
	end else
      if s[i]='i' then
        begin
	if pi<3 then 
	  j:=j+1;
	inc(pi);  
	end else
      end;   
  writeln(j);      
  end;
end.
  