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

#define N 200

int pop(void);
void push(int);

int top=0;
int stack[100];

int main(){
    char s[N];
    int a,b;

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

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

void push(int a){
    top++;
    stack[top] = a;
}
