#include <iostream>
#include <stack>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
stack<int> s;
string in;
getline(cin,in);
int temp = 0;
for(int i=0;i<in.size();i++){
if(in[i]>='0' && in[i]<='9'){
temp = temp*10+(in[i]-'0');
}
else if(in[i] == ' '){
if(temp!=0){
s.push(temp);
// cout << s.top() << "\n";
temp = 0;
}
}
else{
int x = s.top();
s.pop();
int y = s.top();
s.pop();
if(in[i] == '+'){
s.push(y+x);
// cout << s.top() << "\n";
}
else if(in[i] == '-'){
s.push(y-x);
// cout << s.top() << "\n";
}
else{
s.push(y*x);
// cout << s.top() << "\n";
}
}
}
cout << s.top();
}