#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int S[100];
int top;

void push(int x){
    //printf("push %d\n",x);
    top++;
    S[top] = x;
}

int pop(){
    //printf("pop %d\n",S[top]);
    top--;
    return S[top+1];
    
}

int main(void){
    top = 0;
    char x[100];
    int a, b;
    while(scanf("%s",x) != EOF){
        //printf("%s\n",x);
        if(x[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }
        else if(x[0] == '-'){
            a = pop();
            b = pop();
            push(b-a);
        }
        else if(x[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }
        else{
            push(atoi(x));
        }
    }
    printf("%d\n",pop());
    return 0;
}
