//A simple calculator - part 1
//input an expression and press control-D
#include <iostream>
using namespace std;
bool get_N(int& output){
  cin >> ws;
  if( cin.peek()>='0' 
      && cin.peek()<='9' ){
    cin >> output; return true;
  }
  return false;
}

// part 2
bool get_T(int& output){
  int t; char c;
  if( get_N(output) ){
    cin >> ws;
    if( cin.peek()=='*' ){
       cin >> c;
       if( get_T(t) ){
         output = output * t;
         return true;
       }else
         return false;
    }else
      return true;
  }else
    return false;
}

// part 3
bool get_E(int& output){
  int e; char c;
  if( get_T(output) ){
    cin >> ws;
    if( cin.peek()=='+' ){
       cin >> c;
       if( get_E(e) ){
         output = output + e;
         return true;
       }else
         return false;
    }else
      return true;
  }else
    return false;
}

//part 4
int main(){
  int e;
  if( get_E(e) ){
    cout << e << endl;
  }
}
