import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNext()) { // 注意 while 处理多个 case
String sin = in.next();
String temp=sin.replaceAll("\\[]", "");
//将已有匹配的括号用空字符串代替
while (temp.contains("[]")){
temp = temp.replaceAll("\\[]", "");
};
//获得[的数量
long count1 = temp.chars().filter(c -> c == '[').count();
int left = Integer.parseInt(String.valueOf(count1));
//获得]的数量
long count2 = temp.chars().filter(c -> c == ']').count();
int right = Integer.parseInt(String.valueOf(count2));
//在字符串的头部或者尾部添加[或]使字符串达到匹配
for (int i = 0; i < left; i++) {
sin=sin+"]";
}
for (int i = 0; i < right; i++) {
sin="["+sin;
}
System.out.println(sin);
}
}
}