#include<bits/stdc++.h>
using namespace std;
char a[260];
stack<int> s;
int x,y;
void fuhao(char n){
switch (n){
case '+':
x=s.top();
s.pop();
y=s.top();
s.pop();
s.push(x+y);
break;
case '-':
x=s.top();
s.pop();
y=s.top();
s.pop();
s.push(y-x);
break;
case '*':
x=s.top();
s.pop();
y=s.top();
s.pop();
s.push(x*y);
break;
case '/':
x=s.top();
s.pop();
y=s.top();
s.pop();
s.push(y/x);
break;
}
}
bool is_a_num(char c){
if(c>='0'&&c<='9')return 1;
return 0;
}
int main(){
int num=0;
cin.getline(a,250);
int len=strlen(a)-1;
for(int i=0;i<=len;i++){
if(a[i]=='+'||a[i]=='-'||a[i]=='*'||a[i]=='/'){
fuhao(a[i]);
}
else if(a[i]==' '){
continue;
}
else{
num=0;
while(i<=len&&is_a_num(a[i])){
num=num*10+a[i]-'0';
i++;
}
i--;// 回退一个位置,因为 for 循环会再次自增
s.push(num);
}
}
int sev=s.top();
cout<<sev;
return 0;
}