s=p=0
for x in raw_input():z='IVXLCDM'.find(x);x=10**(z/2)*(1,5)[z%2];s+=(x,x-p-p)[p<x];p=x
print s