#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int x[100000]; int main() { string s, t=""; int n,c=0; cin >> s >> n; if (s == "IX") { c = 9; } else { for (int i = 0; i < s.length(); i++) { if (s[i] == 'I') c++; else if (s[i] == 'V')c += 5; else c += 10; } } if (n >= 0) { c = (c + n) % 13; } else { n = n % 24; c = (c + n <= 0) ? 12 + (c + n) : c + n; } if (c == 9) { cout << "IX"; } else { if (c >= 10) { cout << "X"; c -= 10; } else if( c >= 5 ) { cout << "V"; c -= 5; } while (c) { cout << "I"; c--; } } cout << endl; return 0; }