#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
int main() {
string input;
int a, b;
vector<ll> op;
while (cin >> input) {
if (isdigit(input[0])||isdigit(input[1]))
op.push_back(stoi(input));
else {
b = op.back();
op.pop_back();
a = op.back();
op.pop_back();
if (input == "+")
op.push_back(a + b);
else if (input == "-")
op.push_back(a - b);
else if (input == "*")
op.push_back(a * b);
else if (input == "/")
op.push_back(a / b);
else if (input == "%")
op.push_back(a % b);
}
}
cout << op.back() << "\n";
return 0;
}