#include<bits/stdc++.h>
using namespace std;
string a,b;
int num;
int main(){
char cnt;
string s,ans;
while(scanf("%s",&cnt) != EOF){
if(cnt == '['){
scanf("%d",&num);
char cnt2;
while(scanf("%s",&cnt2) != EOF){
if(cnt2 == ']')cout<<ans;
else ans+=cnt2;
}
while(num--)ans+=s;
}
else if(cnt == ']')cout<<ans;
else ans+=cnt;
}
return 0;
}