#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int s[105],p=0;
char in[10];
int main()
{
    while(cin>>in)
        if(in[0]=='+')s[p]+=s[p--];
        else if(in[0]=='-')s[p]-=s[p--];
        else if(in[0]=='*')s[p]*=s[p--];
        else s[++p]=atoi(in);
    cout<<s[1]<<endl;
    return 0;
}
