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

#define MAX 200
int stock[MAX] = {0};
int top;


void push(int x){
    stock[++top] = x;
}

int pop(){
    top--;
    return stock[top+1];
}



int main(){

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