#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #define rep(i,j,k) for(int i=(int)j;i<(int)k;i++) #define repp(i,j,k) for(int i=j;i>=k;i--) #define Sort(x) sort(x.begin(),x.end()); #define ll long long int mod=1e9+7; const int INF = 1e9; using namespace std; int main(void) { string s; int n; cin >> s >> n; int sum = 0; rep(i, 0, s.length()) { if (s[i] == 'X')sum += 10; else if (s[i] == 'V')sum += 5; else sum++; } if (n < 0) { while (n != 0) { n++; sum--; if (sum <1)sum = 12; } } else { while (n != 0) { n--; sum++; if (sum > 12)sum = 1; } } if (sum >= 10) { cout << "X"; sum -= 10; } if (sum >= 5) { cout << "V"; sum -= 5; } rep(i, 0, sum) { cout << "I"; } cout << endl; return 0; }