#include int main(void) { char s[10020]; while(1) { int ptr = 0; int nacteno = 0; while(1) { char c; if(scanf("%c",&c)!=1)return 0; nacteno++; /*printf("%c",c);*/ if(c=='\n')break; {if(c=='i'||c=='I')s[ptr++] = 'I';} {if(c=='v'||c=='V')s[ptr++] = 'V';} {if(c=='x'||c=='X')s[ptr++] = 'X';} {if(c=='l'||c=='L')s[ptr++] = 'L';} {if(c=='c'||c=='C')s[ptr++] = 'C';} {if(c=='d'||c=='D')s[ptr++] = 'D';} {if(c=='m'||c=='M')s[ptr++] = 'M';} } int i; int M=0,D=0,C=0,L=0,X=0,V=0,I=0,lastpos=-1; for(i=0;i2)break;} } for(i=lastpos+1;i2)break;} } for(i=lastpos+1;i2)break;} } if(nacteno) printf("%d\n",M*1000 + D*500 + C*100 + L*50 + X*10 + V*5 + I); } return 0; }