#include <bits/stdc++.h>
using namespace std;
int main() {
  stack<int> mystack;
  string in;
  while (cin >> in) {
    if (in == "+") {
      int x = mystack.top();
      mystack.pop();
      int y = mystack.top();
      mystack.pop();
      int z = x + y;
      mystack.push(z);
    } else if (in == "-") {
      int x = mystack.top();
      mystack.pop();
      int y = mystack.top();
      mystack.pop();
      int z = x - y;
      mystack.push(z);
    } else if (in == "*") {
      int x = mystack.top();
      mystack.pop();
      int y = mystack.top();
      mystack.pop();
      int z = x * y;
      mystack.push(z);
    } else {
      mystack.push(atoi(in.c_str()));
    }
  }
  cout << mystack.top() << endl;
  return 0;
}
