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

using namespace std;

int main(void) {
	string word;
	stack<int> S;
	int x, y;
	while(cin >> word) {
		if (word == "+") {
			x = S.top();
			S.pop();
			y = S.top();
			S.pop();
			S.push(x + y);
		}
		else if (word == "-") {
			x = S.top();
			S.pop();
			y = S.top();
			S.pop();
			S.push(y - x);
		}
		else if (word == "*") {
			x = S.top();
			S.pop();
			y = S.top();
			S.pop();
			S.push(x * y);
		} else {
			S.push(stoi(word));
		}
	}
	cout << S.top() << endl;
}

