public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
Stack<Integer> numStack = new Stack<>();
Stack<String> strStack = new Stack<>();
int num =0;
StringBuffer sb = new StringBuffer("");
for(int i =0;i<s.length();i++){
char c = s.charAt(i);
if(c<='9'&&c>='0'){
num=10*num + c-'0';
}else if(c=='|'){
numStack.push(num);
num = 0;
}else if(c<='Z'&&c>='A'){
sb.append(c);
}else if(c=='['){
strStack.push(sb.toString());//暫存供遇到 ] 時合併生成新的子串
sb= new StringBuffer("");;
}else{
num = numStack.pop();
StringBuffer tmp = new StringBuffer(strStack.pop());
while(num>0){
tmp.append(sb.toString());
num--;
}
sb=new StringBuffer(tmp.toString());
}
}
System.out.println(sb.toString());
}