#include<bits/stdc++.h>
using namespace std;
int main() {
char kind;
cin>>kind;
string s,ans="";
getchar();
getline(cin,s);
if(kind=='C') { //压缩
int i=1,cnt=1;
char x=s[0];
while(i<=s.length()) {
if(s[i]==x) cnt++;
else {
if(cnt==1) ans+=x;
else {
if(cnt>1) ans+=to_string(cnt);
ans.push_back(x);
cnt=1;
}
x=s[i];
}
i++;
}
cout<<ans;
} else { //解压
int i=0,cnt=1;
while(i<s.length()) {
if(s[i]>='0'&&s[i]<='9') {
ans+=s[i];
} else {
if(ans.length()>0) cnt=stoi(ans);
while(cnt--) cout<<s[i];
cnt=1;
ans="";
}
i++;
}
}
return 0;
}
解压的这个思想很有意思