#include <iostream>
using namespace std;

int main(){
    string ss;
    int num[128];
    num['M'] = 1000;
    num['D'] = 500;
    num['C'] = 100;
    num['L'] = 50;
    num['X'] = 10;
    num['V'] = 5;
    num['I'] = 1;
    while( cin >> ss ){
        string::iterator it = ss.begin();
        int answer = 0;
        while( it != ss.end() ){
            if( *it == 'C' && *(it+1) == 'D' ){
                answer += 400; it++;
            }else if( *it == 'X' && *(it+1) == 'C' ){
                answer += 90; it++;
            }else if( *it == 'X' && *(it+1) == 'L' ){
                answer += 40; it++;
            }else if( *it == 'I' && *(it+1) == 'X' ){
                answer += 9; it++;
            }else if( *it == 'I' && *(it+1) == 'V' ){
                answer += 4; it++;
            }else{
                answer += num[*it];
            }
            it++;
        }
        cout << answer << endl;
    }
    return 0;
}