#include<bits/stdc++.h>
using namespace std;
string s , temp;
stack < char > stk;
char ch;
int n , m , sz;
int operator_value( char op );
string Infix_To_Postfix();
int main()
{
cin>>s;
reverse( s.begin(), s.end() );
s = Infix_To_Postfix();
cout<<s<<endl;
return 0;
}
string Infix_To_Postfix()
{
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();
}
reverse ( temp.begin() , temp.end() );
return temp;
}
int operator_value( char op )
{
if ( op == '^' )return 3;
if ( op == '*' || op == '/' )return 2;
if ( op == '+' || op == '-' )return 1;
return -1;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKc3RyaW5nIHMgLCB0ZW1wOwpzdGFjayA8IGNoYXIgPiBzdGs7CmNoYXIgY2g7CmludCBuICwgbSAsIHN6OwppbnQgb3BlcmF0b3JfdmFsdWUoIGNoYXIgb3AgKTsKc3RyaW5nIEluZml4X1RvX1Bvc3RmaXgoKTsKaW50IG1haW4oKQp7CiAgICBjaW4+PnM7CiAgICByZXZlcnNlKCBzLmJlZ2luKCksIHMuZW5kKCkgKTsKICAgIHMgPSBJbmZpeF9Ub19Qb3N0Zml4KCk7CiAgICBjb3V0PDxzPDxlbmRsOwogICAgcmV0dXJuIDA7Cn0Kc3RyaW5nIEluZml4X1RvX1Bvc3RmaXgoKQp7CiAgICBzeiA9IHMuc2l6ZSgpOwogICAgZm9yICggaW50IGkgPSAwOyBpICE9IHN6OyBpKysgKQogICAgewogICAgICAgIGlmICggcyBbIGkgXSA+PSAnYScgJiYgcyBbIGkgXSA8PSAneicgKXRlbXAgKz0gcyBbIGkgXTsKICAgICAgICBlbHNlIGlmICggcyBbIGkgXSA9PSAnKScgKXN0ay5wdXNoKCBzIFsgaSBdICk7CiAgICAgICAgZWxzZSBpZiAoIHMgWyBpIF0gPT0gJygnICkKICAgICAgICB7CiAgICAgICAgICAgIHdoaWxlICggIXN0ay5lbXB0eSgpICYmIHN0ay50b3AoKSAhPSAnKScgKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBjaCA9IHN0ay50b3AoKTsKICAgICAgICAgICAgICAgIHN0ay5wb3AoKTsKICAgICAgICAgICAgICAgIHRlbXAgKz0gY2g7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgc3RrLnBvcCgpOwogICAgICAgIH0KICAgICAgICBlbHNlCiAgICAgICAgewogICAgICAgICAgICB3aGlsZSAoICFzdGsuZW1wdHkoKSAmJiBvcGVyYXRvcl92YWx1ZSggcyBbIGkgXSApIDw9IG9wZXJhdG9yX3ZhbHVlKCBzdGsudG9wKCkgKSApCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGNoID0gc3RrLnRvcCgpOwogICAgICAgICAgICAgICAgc3RrLnBvcCgpOwogICAgICAgICAgICAgICAgaWYgKCBjaCAhPSAnKScgJiYgY2ggIT0gJygnICl0ZW1wICs9IGNoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHN0ay5wdXNoKCBzIFsgaSBdICk7CiAgICAgICAgfQogICAgfQogICAgd2hpbGUgKCAhc3RrLmVtcHR5KCkgKQogICAgewogICAgICAgIGlmICggc3RrLnRvcCgpICE9ICcoJyAmJiBzdGsudG9wKCkgIT0gJyknICl0ZW1wICs9IHN0ay50b3AoKTsKICAgICAgICBzdGsucG9wKCk7CiAgICB9CiAgICByZXZlcnNlICggdGVtcC5iZWdpbigpICwgdGVtcC5lbmQoKSApOwogICAgcmV0dXJuIHRlbXA7Cn0KaW50IG9wZXJhdG9yX3ZhbHVlKCBjaGFyIG9wICkKewogICAgaWYgKCBvcCA9PSAnXicgKXJldHVybiAzOwogICAgaWYgKCBvcCA9PSAnKicgfHwgb3AgPT0gJy8nIClyZXR1cm4gMjsKICAgIGlmICggb3AgPT0gJysnIHx8IG9wID09ICctJyApcmV0dXJuIDE7CiAgICByZXR1cm4gLTE7Cn0K