list = ["I", "II", "III", "IIII", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII"] time, count = gets.split.map(&:to_s) start_time = 0 for i in 0...list.size do start_time = i if time == list[i] end end_time = start_time + count.to_i if end_time >= 24 while end_time >= 12 end_time -= 12 end elsif end_time < 0 end_time *= -1 while end_time >= 12 end_time -= 12 end end_time *= -1 end puts end_time >= 12 ? list[end_time - 12] : list[end_time]