import Maybe r=foldl(\t c->t+y c-t`mod`y c*2)0 y x=fromJust$lookup x$zip"IVXLCDM"[1,5,10,50,100,500,1000] m@main=getLine>>=print.r>>m