using System; namespace ATCoder { class Program { static void Main(string[] args) { string s = Console.ReadLine(); string roma = s.Split(' ')[0]; int t = int.Parse(s.Split(' ')[1]); int current = 0; foreach (char c in roma) { if (c == 'X') { current += 10; } else if(c == 'V') { current += 5; } else if(c == 'I') { current += 1; } } while (t < 0) { t += 12; } int time; time = current + t; time %= 12; string p = ""; switch (time) { case 0: p = "XII";break; case 1: p = "I";break; case 2: p = "II";break; case 3: p = "III";break; case 4: p = "IIII";break; case 5: p = "V";break; case 6: p = "VI";break; case 7: p = "VII";break; case 8: p = "VIII";break; case 9: p = "IX";break; case 10: p = "X";break; case 11: p = "XI";break; case 12: p = "XII";break; } Console.WriteLine(p); } } }