#include <iostream>
#include <string>
#include <algorithm>
#include <stack>

using namespace std;

string toReversePorland(string str){
  string hand;
  string side;

  // ÊàtO                                                                          
  bool isInside = false;

  for(int i = 0; i < str.size(); i++){
    //    cout << str[i] << endl;                                                          
    //    cout << hand << endl;                                                            
    //    cout << side << endl;                                                            

    if(str[i] >= '0' && str[i] <= '9'){
      hand += str[i];
    }
    else if(str[i] == '('){
      isInside = true;
      side += str[i];
    }
    else if(isInside && str[i] == ')'){
      // EÊÜÅZqðêÂ¸Âè³Éß·                                              
      //      cout << side << endl;                                                        
      for(int j = side.size()-1 ; ;j--){
        if(side[j] == '('){
          if(j != 0){
            side = side.substr(0,j) + "";
            //      cout << side << endl;                                                  
          }
          else
            side = "";
          break;
        }
	else{
          hand += side[j];
        }
      }
      isInside = false;
    }

    else{
      if(side.size() == 0){
        side += str[i];
      }
      else if(str[i] == '+' || str[i] == '-'){
        if(side[side.size()-1] == '*' || side[side.size()-1] == '/'){
          hand += side[side.size()-1];
          side[side.size()-1] = str[i];
        }
        else{
          //      cout << str[i] << endl;                                                  
          side += str[i];
        }
      }
      else{
        if(side[side.size()-1] == '*' || side[side.size()-1] == '/'){
          hand += side[side.size()-1];
          side[side.size()-1] = str[i];
        }
        else
          side += str[i];
      }
    }
  }

  for(int i = side.size()-1; i >= 0; i--){
    hand += side[i];
  }
  return hand;
}

int calc(string str){

  cout << str << endl;
  //  string stack;                                                                        
  stack<int> st;
  for(int i = 0; i < str.size(); i++){
    if(str[i] >= '0' && str[i] <= '9'){
      st.push(str[i] - '0');
    }
    else{
      int val[2];
      val[0] = st.top();
      st.pop();
      val[1] = st.top();
      st.pop();
      if(str[i] == '+'){
	st.push(val[0] + val[1]);
      }
      if(str[i] == '-'){
	st.push(val[1] - val[0]);
      }
      if(str[i] == '*'){
	st.push(val[0] * val[1]);
      }
      if(str[i] == '/'){
	st.push(val[1] / val[0]);
      }
    }
  }
  return st.top();
}

int main(){

  string str;
  getline(cin,str);

  cout << calc(toReversePorland(str)) << endl;

  return 0;
}