#include <bits/stdc++.h>

using namespace std;

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

    cout << ans << endl;
  }

  return 0;
}
