#include <bits/stdc++.h>
using namespace std;

int main() {
	map<char, int> roman;
	roman['I'] = 1;
	roman['V'] = 5;
	roman['X'] = 10;
	roman['L'] = 50;
	roman['C'] = 100;
	roman['D'] = 500;
	roman['M'] = 1000;
	string s;
	while(cin >> s){
		int ans = roman[s[0]];
		for(int i = 1; i < s.size(); ++i){
			if(roman[s[i - 1]] >= roman[s[i]])
				ans += roman[s[i]];
			else
			 	ans += roman[s[i]] - roman[s[i - 1]] - roman[s[i - 1]];
		}
		cout << ans << endl;
	}
	return 0;
}