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