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