#include using namespace std; int main(){ string str; int t; cin >> str >> t; if(t < 0){ t = 12 - (abs(t) % 12); } int time = 0; for(int i = 0; i < str.length(); i++){ if(str[i] == 'X') time += 10; else if(str[i] == 'I') time++; else time += 5; } int ans = (time + t) % 12; if(ans == 9){ cout << "IX"; }else{ int ten = ans / 10; ans -= ten * 10; int five = ans / 5; ans -= five * 5; int one = ans; for(int i = 0; i < ten; i++){ cout << "X"; } for(int i = 0; i < five; i++){ cout << "V"; } for(int i = 0; i < one; i++){ cout << "I"; } } cout << endl; }