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