#include <iostream>
#include <cstdlib>

template <typename T>
class stack{
  T a[101];
  unsigned n;
public:
  stack():a(),n(0){}
  T& top(){return a[n-1];}
  T pop(){return a[--n];}
  void push(T in){a[n++]=in;}
};

int main(){
  std::ios::sync_with_stdio(false);
  stack<int> s;
  char buf[100];

  while(std::cin >> buf){
    int a;
    switch(buf[0]){
      case '+' : a = s.pop(); s.top() += a; break;
      case '-' : a = s.pop(); s.top() -= a; break;
      case '*' : a = s.pop(); s.top() *= a; break;
      default  : s.push(atoi(buf));
    }
  }
  std::cout << s.top() << '\n';
}