#include <iostream>
using namespace std;
const int N = 200;
void revers(char * res, int &n) {
char a;
cin >> a;
if (a == ')') return;
else revers(res, n);
res[n++] = a;
}
int main() {
char res[N];
char a;
int n = 0;
while (cin >> a) {
if (a == '(') revers(res, n);
else res[n++] = a;
}
for (int i = 0; i < n; i++)
cout << res[i];
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE4gPSAyMDA7Cgp2b2lkIHJldmVycyhjaGFyICogcmVzLCBpbnQgJm4pIHsKICAgY2hhciBhOwogICBjaW4gPj4gYTsKICAgaWYgKGEgPT0gJyknKSByZXR1cm47CiAgIGVsc2UgcmV2ZXJzKHJlcywgbik7CiAgIHJlc1tuKytdID0gYTsKfQoKaW50IG1haW4oKSB7CiAgIGNoYXIgcmVzW05dOwogICBjaGFyIGE7CiAgIGludCBuID0gMDsKICAgd2hpbGUgKGNpbiA+PiBhKSB7CiAgICAgIGlmIChhID09ICcoJykgcmV2ZXJzKHJlcywgbik7CiAgICAgIGVsc2UgcmVzW24rK10gPSBhOwogICB9CiAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQogICAgICBjb3V0IDw8IHJlc1tpXTsKICAgcmV0dXJuIDA7Cn0=