import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s1 = sc.next(); int T = sc.nextInt(); String[] time = {"XII", "I","II","III","IIII","V","VI","VII","VIII","IX","X","XI"}; int s = 0; if(s1.contains("V")) { s = s1.length() + 4; } else if(s1.contains("X")) { if(s1.charAt(0) == 'I') { s = 9; } else { s = s1.length() + 9; } } else { s = s1.length(); } s += T; if(s >= 0) { s = s % 12; } else { s = (-s) % 12; s = 12 - s; if(s == 12) s = 0; } System.out.println(time[s]); } }