#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<string>
#include<cstring>
using namespace std;
stack<string>s;
string ans;
int main() {
char input[50004];
scanf("%s", input);
int len = strlen(input);
char pre = ' ';
for (int i = 0; i < len; i++) {
if (input[i] == '[') { pre = input[i]; continue; }
if (pre == '[' && input[i] == ']'){pre=']';continue;}
if (input[i] >= '1' && input[i] <= '9' && pre == '[') {
string num;
while (input[i] >= '1' && input[i] <= '9') { num += input[i]; i++; }
s.push(num); i--; pre = input[i]; continue;
}
if (s.empty()) {
ans += input[i]; pre = input[i]; continue;
}
if (!s.empty()) {
string now;
while (input[i] != ']') {
now += input[i]; i++;
}
int flag = 0;
while (!s.empty()) {
int hh = stoi(s.top());
s.pop();
i++;
string now1 = now;
for (int j = 0; j < hh - 1; j++) {
now += now1;
}
}
i--;
pre = ']';
ans += now;
}
}
printf("%s\n", ans.c_str());
return 0;
}