#include<iostream>
#include<map>
#include<string>

using namespace std;

int main() {
	
	map<char, int> Map;
	Map['I'] = 1;
    Map['V'] = 5;
    Map['X'] = 10;
    Map['L'] = 50;
    Map['C'] = 100;
    Map['D'] = 500;
    Map['M'] = 1000;
    
    string roman_num;
    
    while( cin >> roman_num) {
    	
    	int sum = 0;
    	
    	for(int i=0;i<roman_num.size();i++) {
    		
    		if( Map[roman_num[i]] < Map[roman_num[i+1]] )
    		sum -= Map[roman_num[i]];
    		else
    		sum += Map[roman_num[i]];
    		
		}
    	
    	cout << sum << "\n";
    	
	}

	return 0;
}
