s=p=0
for x in raw_input():x=dict(zip('IVXLCDM',(1,5,10,50,100,500,1000)))[x];s+=(x,x-p-p)[p<x];p=x
print s
