#include <bits/stdc++.h>
using namespace std;
stack<int> s;
char op[3333];
int main(){
    gets(op);
    int len = strlen(op);
    int n = 0;
    for(int i = 0; i < len; i++){
        if(op[i] >= '0' && op[i] <= '9'){
            n = n*10 + (op[i]-'0');
        }
        else if(op[i] == ' ' && op[i-1] >= '0' && op[i-1] <= '9'){
            s.push(n);
            n = 0;
        }
        else if(op[i] == '+' || op[i] == '-' || op[i] == '*' || op[i] == '/'){
            int y = s.top();
            s.pop();
            int x = s.top();
            s.pop();
            if(op[i] == '+'){
                s.push(x+y);
            }
            else if(op[i] == '-'){
                s.push(x-y);
            }
            else if(op[i] == '*'){
                s.push(x*y);
            }
            else if(op[i] == '/'){
                s.push(x/y);
            }
        }
    }
    cout << s.top();
}

