#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#define N 100
int pop(void);
void push(int);
int top=0,S[N];
int main(){
    
    char s[N];
    int a,b;
    
    while(scanf("%s",s) != EOF){
        if(s[0] == '+'){
            push(pop() + pop());
        }
        else if(s[0] == '-'){
            a = pop();
            b = pop();
            push(b-a);
        }
        else if(s[0] == '*'){
            push(pop() * pop());
        }
        else{
            push(atoi(s));
        }
    }
    printf("%d\n",pop());
}

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

void push(int num){
    S[++top] = num;
}

