n=p=0 for c in raw_input(): x=[1000,500,100,50,10,5,1]['MDCLXVI'.find(c)] if p