#include<iostream>
#include<string>
using namespace std;
string cypher;
void decypher()
{
for (;;)
{
int right = cypher.find_first_of(']');
if (-1 == right)
return;
int left = cypher.substr(0, right).find_last_of('[');
string sub = "", temp = "";
int length = 0;
if (isdigit(cypher[left + 2]))
{
length = (cypher[left + 1] - '0') * 10 + cypher[left + 2] - '0';
sub = cypher.substr(left + 3, right - left - 3);
}
else
{
length = cypher[left + 1] - '0';
sub = cypher.substr(left + 2, right - left - 2);
}
for (int i = 0; i < length; i++)
temp += sub;
cypher = cypher.substr(0, left) + temp + cypher.substr(right + 1);
}
}
int main()
{
cin >> cypher;
decypher();
cout << cypher;
return 0;
}