var readline=require("readline"); var r2=readline.createInterface({ input:process.stdin, output:process.stdout }); var arr1 = []; r2.on("line",function(line){ arr1.push(line); var str=line; if(str) { var n= howManyTimesPopStr(str); console.log(n.join("")); } }) function howManyTimesPopStr(s){ //京东的第二道笔试题 var str=s; var count=0,i=0,j,stack=[],arr=[],sum=1; while(i<str.length){ switch(str[i]){ case "[": stack.push(str[i]); arr.push(str[i]); count++; break; case "]": var x=stack[stack.length-1]; if(x=='['){ stack.pop(); arr.push(']'); }else{ stack.push("]"); arr.push(']'); } break; } i++; } while(stack.length>0){ var x=stack.pop(); if(x=='['){ arr.push(']'); }else{ arr.unshift('['); } } return arr; }