#include
#include
#include
using namespace std;
class Solution{
static int calRPN(vector& s){
//首先创建个栈使用
stack sta;
for(auto x: s){
if(x == "+" || x == "-" || x == "*" || x == "/"){//如果该字符是操作符
if(sta.size()<2) return 0;//如果栈内数字不足两个,即无法进行运算,则返回0
int a = sta.top();
sta.pop();//依次将栈内两个数字出栈进行操作运算
int b = sta.top();
sta.pop();
int c = 0;//用c表示每次运算的结果
if(x == "+") c=b+a;
if(x == "-") c=b-a;
if(x == "*") c=b*a;
if(x == "/") c=b/a;
sta.push(c);
}else{
sta.push(atoi(x.c_str()));
//操作数入栈,注意先将string字符串转为char字符,再转为int数字
}
}
return sta.top();
}
};
int main(){
vector str;
string s;
cin>>s;
str.push_back(s);
cout<calRPN(str)<<endl;
return 0 ;
}