#include template T in() { abort(); return T(); } template<> std::string in() { std::string str; std::cin >> str; return str; } template<> int in() { int x; scanf("%d", &x); return x; } template void out(T x) { abort(); } template<> void out(std::string x) { std::cout << x << std::endl; } template<> void out(int x) { printf("%d\n", x); } int main() { std::map map; map["I"] = 1; map["II"] = 2; map["III"] = 3; map["IIII"] = 4; map["V"] = 5; map["VI"] = 6; map["VII"] = 7; map["VIII"] = 8; map["IX"] = 9; map["X"] = 10; map["XI"] = 11; map["XII"] = 12; auto str = in(); auto x = in(); int t = (map[str] + 12000 + x) % 12; if( t == 0 ) t = 12; for(auto sy : map) { if( sy.second == t ) { printf("%s\n", sy.first.c_str()); } } return 0; }