#include <stdio.h>
#include <stdlib.h>
#define N 200
int main(){
    char c[N];
    int s[N], top = 0;
    int x, y;
    while(scanf("%s", c) != EOF){
        if(c[0] == '+'){
            top = top-1;
            x = s[top+1];
            top = top-1;
            y = s[top+1];
            top++;
            s[top] = x + y;
        }
        else if(c[0] == '-'){
            top = top-1;
            x = s[top+1];
            top = top-1;
            y = s[top+1];
            top++;
            s[top] = y - x;
        }
        else if(c[0] == '*'){
            top = top-1;
            x = s[top+1];
            top = top-1;
            y = s[top+1];
            top++;
            s[top] = x * y;
        }
        else{
            x = atoi(c);
            top++;
            s[top] = x;
        } }
    printf("%d\n", s[top]);
    return 0;
                }
