#include using namespace std; string dec2rome(int n) { string ans; int rep; if (n <= 4) { rep = n; } else if (n <= 8) { ans = "V"; rep = n - 5; } else if (n == 9) { return "IX"; } else { ans = "X"; rep = n - 10; } for (int i = 0; i < rep; i++) ans += "I"; return ans; } int rome2dec(string s) { map m; m['I'] = 1; m['V'] = 5; m['X'] = 10; int ans = 0, prev = 0; for (char c : s) { ans += m[c]; if (m[c] > prev) ans -= 2 * prev; prev = m[c]; } return ans; } int main() { string s; int t; cin >> s >> t; cout << dec2rome((rome2dec(s) + t + 1199) % 12 + 1) << endl; }