#include<iostream>
#include<stack>
#include<cstdlib>
using namespace std;
int main()
{
    int a,b;
    stack<int> s;
    string c;
    while(cin>>c)
    {
        if(c[0]=='+'){a=s.top();s.pop();b=s.top();s.pop();s.push(a+b);}
        else if(c[0]=='-'){a=s.top();s.pop();b=s.top();s.pop();s.push(b-a);}
        else if(c[0]=='*'){a=s.top();s.pop();b=s.top();s.pop();s.push(a*b);}
        else
            s.push(atoi(c.c_str()));//atoi()
    }
    cout<<s.top()<<endl;
    s.pop();
    return 0;
}