import java.util.Scanner; public class RomeNumber { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner s = new Scanner(System.in); String S1 = s.next(); int T = s.nextInt(),now = 0; s.close(); if(S1.contains("V")){ now += 5; }else if(S1.contains("X")){ now += 10; } if(S1.contains("I")){ now +=( S1.lastIndexOf("I") - S1.indexOf("I") + 1); } if(S1.equals("IX")){ now = 9; } now += T; while(now < 0){ now += 12; //System.out.println(now); } now %= 12; StringBuilder ans = new StringBuilder(); if(now == 9){ ans.append("IX"); }else if(now == 0){ ans.append("XII"); }else if(now / 5 == 1){ ans.append("V"); }else if(now / 5 == 2){ ans.append("X"); } if(now != 9 && now != 0){ for(int i = 0;i < now%5;i++){ ans.append("I"); } } System.out.println(ans); } }