# 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
def roman(n):
num = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000]
symbol = ["I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD", "D", "CM", "M"]
i = 12
while n:
div = n//num[i]
n%=num[i]
while div:
print(symbol[i])
div -=1
i-=1
n = int(raw_input())
print (roman(n))
IyBDb252ZXJ0IGRlY2ltYWwgbnVtYmVyIGx5aW5nIGJldHdlZW4gMS0zOTk5IHRvIHJvbWFuIG51bWVyYWxzCiMgU1lNQk9MICAgICAgIFZBTFVFCiMgSSAgICAgICAgICAgICAxCiMgSUkJCQkgIDIKIyBJSUkJCQkgIDMKIyBJViAgICAgICAgICAgIDQKIyBWICAgICAgICAgICAgIDUKIyBYICAgICAgICAgICAgIDEwCiMgTCAgICAgICAgICAgICA1MAojIEMgICAgICAgICAgICAgMTAwCiMgRCAgICAgICAgICAgICA1MDAKIyBNICAgICAgICAgICAgIDEwMDAgICAgIAoKZGVmIHJvbWFuKG4pOgoJbnVtID0gWzEsIDQsIDUsIDksIDEwLCA0MCwgNTAsIDkwLCAxMDAsIDQwMCwgNTAwLCA5MDAsIDEwMDBdCglzeW1ib2wgPSBbIkkiLCAiSVYiLCAiViIsICJJWCIsICJYIiwgIlhMIiwgIkwiLCAiWEMiLCAiQyIsICJDRCIsICJEIiwgIkNNIiwgIk0iXQoJaSA9IDEyCgl3aGlsZSBuOgoJCWRpdiA9IG4vL251bVtpXQoJCW4lPW51bVtpXQoJCQoJCXdoaWxlIGRpdjoKCQkJcHJpbnQoc3ltYm9sW2ldKQoJCQlkaXYgLT0xCgkJaS09MQoJCgpuID0gaW50KHJhd19pbnB1dCgpKQpwcmludCAocm9tYW4obikp