#include<bits/stdc++.h>
using namespace std;
string s;
int sz , n , m;
char ch, ch2;
int operator_value( char op );
void Infix_To_Postfix();
stack < char > stk;
int main()
{
cin>>s;
Infix_To_Postfix();
return 0;
}
void Infix_To_Postfix()
{
string temp;
sz = s.size();
for ( int i = 0; i != sz; i++ )
{
if ( s [ i ] >= 'a' && s [ i ] <= 'z' )temp += s [ i ];
else if ( s [ i ] == '(' )stk.push( s [ i ] );
else if ( s [ i ] == ')' )
{
while ( !stk.empty() && stk.top() != '(' )
{
ch = stk.top();
stk.pop();
temp += ch;
}
stk.pop();
}
else
{
while ( !stk.empty() && operator_value( s [ i ] ) <= operator_value( stk.top() ) )
{
ch = stk.top();
stk.pop();
if ( ch != '(' && ch != ')' )temp += ch;
}
stk.push( s [ i ] );
}
}
while ( !stk.empty() ){if(stk.top() != '(' && stk.top() != ')' )temp += stk.top();stk.pop();}
cout<<temp<<endl;
}
int operator_value( char op )
{
if ( op == '^' )return 3;
if ( op == '*' || op == '/' )return 2;
if ( op == '+' || op == '-' )return 1;
return -1;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKc3RyaW5nIHM7CmludCBzeiAsIG4gLCBtOwpjaGFyIGNoLCBjaDI7CmludCBvcGVyYXRvcl92YWx1ZSggY2hhciBvcCApOwp2b2lkIEluZml4X1RvX1Bvc3RmaXgoKTsKc3RhY2sgPCBjaGFyID4gc3RrOwppbnQgbWFpbigpCnsKICAgIGNpbj4+czsKICAgIEluZml4X1RvX1Bvc3RmaXgoKTsKICAgIHJldHVybiAwOwp9CnZvaWQgSW5maXhfVG9fUG9zdGZpeCgpCnsKICAgIHN0cmluZyB0ZW1wOwogICAgc3ogPSBzLnNpemUoKTsKICAgIGZvciAoIGludCBpID0gMDsgaSAhPSBzejsgaSsrICkKICAgIHsKICAgICAgICBpZiAoIHMgWyBpIF0gPj0gJ2EnICYmIHMgWyBpIF0gPD0gJ3onICl0ZW1wICs9IHMgWyBpIF07CiAgICAgICAgZWxzZSBpZiAoIHMgWyBpIF0gPT0gJygnIClzdGsucHVzaCggcyBbIGkgXSApOwogICAgICAgIGVsc2UgaWYgKCBzIFsgaSBdID09ICcpJyApCiAgICAgICAgewogICAgICAgICAgICB3aGlsZSAoICFzdGsuZW1wdHkoKSAmJiBzdGsudG9wKCkgIT0gJygnICkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY2ggPSBzdGsudG9wKCk7CiAgICAgICAgICAgICAgICBzdGsucG9wKCk7CiAgICAgICAgICAgICAgICB0ZW1wICs9IGNoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHN0ay5wb3AoKTsKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgIHsKICAgICAgICAgICAgd2hpbGUgKCAhc3RrLmVtcHR5KCkgJiYgb3BlcmF0b3JfdmFsdWUoIHMgWyBpIF0gKSA8PSBvcGVyYXRvcl92YWx1ZSggc3RrLnRvcCgpICkgKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBjaCA9IHN0ay50b3AoKTsKICAgICAgICAgICAgICAgIHN0ay5wb3AoKTsKICAgICAgICAgICAgICAgIGlmICggY2ggIT0gJygnICYmIGNoICE9ICcpJyApdGVtcCArPSBjaDsKICAgICAgICAgICAgfQogICAgICAgICAgICBzdGsucHVzaCggcyBbIGkgXSApOwogICAgICAgIH0KICAgIH0KICAgIHdoaWxlICggIXN0ay5lbXB0eSgpICl7aWYoc3RrLnRvcCgpICE9ICcoJyAmJiBzdGsudG9wKCkgIT0gJyknICl0ZW1wICs9IHN0ay50b3AoKTtzdGsucG9wKCk7fQogICAgY291dDw8dGVtcDw8ZW5kbDsKfQppbnQgb3BlcmF0b3JfdmFsdWUoIGNoYXIgb3AgKQp7CiAgICBpZiAoIG9wID09ICdeJyApcmV0dXJuIDM7CiAgICBpZiAoIG9wID09ICcqJyB8fCBvcCA9PSAnLycgKXJldHVybiAyOwogICAgaWYgKCBvcCA9PSAnKycgfHwgb3AgPT0gJy0nIClyZXR1cm4gMTsKICAgIHJldHVybiAtMTsKfQ==