#include<iostream>
#include<stack>
#include<string>
using namespace std;
int acc(int a,int b,char p){
if(p == '+'){
return a + b;
}
if(p == '-'){
return a - b;
}
if(p == '*'){
return a * b;
}
if(p == '/'){
return a / b;
}
}
int main(){
string str;
cin>>str;
stack<int>s;
for(int i = 0;i < str.length();i++){
if(str[i] >= '0'&&str[i] <= '9'){
s.push(str[i] - '0');
}else{
int b = s.top();
s.pop();
int a = s.top();
s.pop();
s.push(acc(a,b,str[i]));
}
}
cout<<s.top()<<endl;
return 0;
}