#include <iostream>
#include <string>
#define len s.length()
using namespace std;
int q[100001], top;
string s, t;
int main() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
cin >> s;
for (int i = 0; i < len; i++) {
if (s[i] == '(') {q[++top] = i; t[i]=')';}
if (s[i] == '[') {q[++top] = i; t[i]=']';}
if (s[i] == ')' || s[i] == ']')
if (!top || t[q[top]] != s[i])
if (s[i] == ')') t[i] = '(';
else t[i] = '[';
else t[q[top--]] = ' ';
}
for (int i = 0; i < len; i++) {
if (t[i] == '(' || t[i] == '[') cout << t[i];
cout << s[i];
if (t[i] == ')' || t[i] == ']') cout << t[i];
}
return 0;
}