#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
    string s;
    while(cin>>s){
        int i=0,v=0,x=0,l=0,c=0,d=0,m=0;
        for(int n=0;n<s.size();n++){
            if(s[n]=='I'){
                i++;
            }
            if(s[n]=='V'){
                v++;
            }
            if(s[n]=='X'){
                x++;
            }
            if(s[n]=='L'){
                l++;
            }
            if(s[n]=='C'){
                c++;
            }
            if(s[n]=='D'){
                d++;
            }
            if(s[n]=='M'){
                m++;
            }
        }
        cout<<m*1000+d*500+c*100+l*50+x*10+v*5+i*1<<endl;
    }
    return 0;
}