s=[[1,5,10,50,100,500,1000]["IVXLCDM".find(c)]for c in raw_input()] t=l=0 while s:i=s.pop();t+=(i,-i)[l>i];l=i print t