d = ["XII","I","II","III","IIII","V","VI","VII","VIII","IX","X","XI"] from datetime import datetime, timedelta s, t = input().split() h = d.index(s) dt = datetime(2000, 1, 1, h, 0) dt += timedelta(hours=int(t)) print(d[dt.hour%12])