 
 #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   string s;
   while(cin>>s)
   {
     int sum=0;
     for(int i=0;i<s.length();i++)
     {
       if(s[i]=='I') 
       {
         if(i+1<s.length()&&s[i+1]!='I') sum-=1;
         else sum+=1;              
       }  
       if(s[i]=='V') sum+=5;
       if(s[i]=='X') sum+=10;
       if(s[i]=='L') sum+=50;  
       if(s[i]=='C') sum+=100;
       if(s[i]=='D') sum+=500;   
       if(s[i]=='D') sum+=1000;    
     }             
     cout<<sum<<endl;
   }
   //while(1);
   return 0;
 }