#include<bits/stdc++.h> using namespace std; string f(){ string s="",x=""; int d; char c; while(cin>>c){ if(c=='['){ cin>>d; x=f(); while(d--){ s+=x; } } else if(c==']'){ return s; } else s+=c; } } int main(){ cout<<f(); return 0; }