#include<bits/stdc++.h>
using namespace std;
int main(){
stack<char> mystack;
char x,a;
int num=0,k=1;
string s="",rs="";
while(cin.get(a)){
if(a=='\n') {
while(!mystack.empty()){
x=mystack.top();
mystack.pop();
s=x+s;
}
break;
}
else if(a!=']') {
mystack.push(a);
}
else if(a==']'){
s="";
x=mystack.top();
while(x!='['){
if(x>='A'&&x<='Z'){
rs=x+rs;
mystack.pop();
x=mystack.top();
}
else{
num+=int(x-'0')*k;
k*=10;
mystack.pop();
x=mystack.top();
}
}
mystack.pop();
for(int i=1;i<=num;i++){
s+=rs;
}
num=0;k=1;rs=s;
}
}
cout<<s;
return 0;
}