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; s = s % 12; System.out.println(time[s]); } }