#include<bits/stdc++.h>
using namespace std;
int main(){
stack<int> s;
string a;
cin>>a;
int ans=0,x=0,y=0;
for(int i=0;i<a.size()-1;i++)
{
if(a[i]=='.')
{
s.push(a[i-1]-48);
}
if(a[i]=='+')
{
x=s.top();
s.pop();
y=s.top();
s.pop();
ans=y+x;
s.push(ans);
ans=0;
}
if(a[i]=='-')
{
x=s.top();
s.pop();
y=s.top();
s.pop();
ans=y-x;
s.push(ans);
ans=0;
}
if(a[i]=='*')
{
x=s.top();
s.pop();
y=s.top();
s.pop();
ans=y*x;
s.push(ans);
ans=0;
}
if(a[i]=='/')
{
x=s.top();
s.pop();
y=s.top();
s.pop();
ans=y/x;
s.push(ans);
ans=0;
}
}
cout<<s.top()<<endl;
return 0;
}