#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <ctime>

using namespace std;

int main()
{
 string s;
 getline(cin,s);
 string desetice;
 int i=0;
 int flag=0;
 while(s[i]!='V' && s[i]!='I'){desetice+=s[i];i++;}
 string jedinice;
 while(i<s.size()){jedinice+=s[i];i++;}
 if(desetice[desetice.size()-1]=='X' &&  jedinice[0]=='I'){flag=8;}
 for(int x=0;x<desetice.size()-1;x++){if(desetice[x]=='L' && desetice[x+1]=='X' && (desetice[x+2]!='X' || flag==8)){cout<< "XL";
 if(x==desetice.size()-2)flag=1;
 x+=2;
 }
                                      else cout << desetice[x];
                                      }
 if(desetice[desetice.size()-1]=='X' &&  jedinice[0]=='I' && flag!=1){cout << "IX";flag=2;}
 else if(flag!=1)cout << desetice[desetice.size()-1];
 for(int x=0;x<jedinice.size();x++){if(flag==2){x++;flag=0;}
                                    else if(jedinice[x]=='V' && jedinice[x+1]=='I' && jedinice[x+2]!='I'){cout << "IV";x+=2;}
                                    else cout << jedinice[x];
                                    }                                   
 

 
  system("pause");
    return 0;
}
