
#include<bits/stdc++.h>
using namespace std;
string change(int digit,int unit){
string s;
if(digit>0&&digit<4) {
for(int i=0;i<digit;i++){
if(unit==1) s+='I';
else if(unit==2) s+='X';
else if(unit==3) s+='C';
else if(unit==4) s+='M';
}
}else if(digit==4){
if(unit==1) s="IV";
else if(unit==2) s="XL";
else if(unit==3) s="CD";
}else if(digit==5){
if(unit==1) s="V";
else if(unit==2) s="L";
else if(unit==3) s="D";
}else if(digit>5&&digit<9){
if(unit==1) s="V";
else if(unit==2) s="L";
else if(unit==3) s="D";
for(int i=5;i<digit;++i){
if(unit==1) s=s+"I";
else if(unit==2) s=s+"X";
else if(unit==3) s=s+"C";
}
}else if(digit==9){
if(unit==1) s="IX";
else if(unit==2) s="XC";
else if(unit==3) s="CM";
}
return s;
}
int main(){
int num,unit=1;
cin>>num;
string res;
while(num>0){
int temp=num%10;
res=change(temp,unit++)+res;
num=num/10;
}
cout<<res;
return 0;
}