import java.util.*; public class Main { private static Scanner sc = new Scanner(System.in); public static void main(String[] args) throws Exception { Map map = new HashMap<>(); map.put("I", 1); map.put("II", 2); map.put("III", 3); map.put("IIII", 4); map.put("V", 5); map.put("VI", 6); map.put("VII", 7); map.put("VIII", 8); map.put("IX", 9); map.put("X", 10); map.put("XI", 11); map.put("XII", 12); String s = sc.next(); int t = map.get(s); int diff = sc.nextInt() % 12; diff = diff < 0 ? diff + 12 : diff; t += diff; if (t > 12) t -= 12; for (Map.Entry entry : map.entrySet()) { if (entry.getValue() == t) { System.out.println(entry.getKey()); } } } }