#include <iostream>
#include <string>
using namespace std;
/**
Convert decimal number lying between 1-3999 to roman numerals
SYMBOL VALUE
I 1
II 2
III 3
IV 4
V 5
X 10
L 50
C 100
D 500
M 1000
**/
//3999 - MMMCMXCIX
string roman(int n){
string s = "";
int tho = n / 1000;
while(tho--) {
s= s+"M";
}
n = n % 1000;
int hun = n / 100;
if(hun == 9) {
s+= "CM";
} else if (hun >= 5) {
s+= "D";
while(hun-- > 5) {
s+= "C";
}
} else {
if(hun == 4) {
s+= "CD";
} else {
while(hun--) {
s += "C";
}
}
}
n = n % 100;
int ten = n / 10;
if(ten == 9) {
s+= "XC";
} else if (ten >= 5) {
s+="L";
while(ten-- > 5) {
s+="X";
}
} else {
if(ten == 4) {
s+= "XL";
} else {
while(ten --) {
s+= "X";
}
}
}
n = n % 10;
if(n == 9) {
s+= "IX";
} else if (n >= 5) {
s+= "V";
while(n-- > 5) {
s+= "I";
}
} else {
if(ten == 4) {
s+= "IV";
} else {
while(n--) {
s+= "I";
}
}
}
return s;
}
int main() {
int intNum = 0;
cin >> intNum;
cout << roman(intNum);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKLyoqCkNvbnZlcnQgZGVjaW1hbCBudW1iZXIgbHlpbmcgYmV0d2VlbiAxLTM5OTkgdG8gcm9tYW4gbnVtZXJhbHMKClNZTUJPTCAgICAgICBWQUxVRQpJICAgICAgICAgICAgIDEKSUkJCQkgIDIKSUlJCQkJICAzCklWICAgICAgICAgICAgNApWICAgICAgICAgICAgIDUKWCAgICAgICAgICAgICAxMApMICAgICAgICAgICAgIDUwCkMgICAgICAgICAgICAgMTAwCkQgICAgICAgICAgICAgNTAwCk0gICAgICAgICAgICAgMTAwMCAgICAgCioqLwoKLy8zOTk5IC0gTU1NQ01YQ0lYCnN0cmluZyByb21hbihpbnQgbil7CglzdHJpbmcgcyA9ICIiOwoJaW50IHRobyA9IG4gLy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