#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 128
int data[MAX];
int top = 0;
void initialize();
int isFull();
int isEmpty();
void push(int);
int pop();
int main(void){
    int a, b;
    char s[100];
    while(scanf("%s", s) != EOF){
        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;
}
void initialize(){
    top = 0;
    return;
}
int isFull(){
    return top == MAX;
}
int isEmpty(){
    return top == 0;
}
void push(int num){
    top++;
    data[top] = num;
    return;
}
int pop(){
    top--;
    return data[top+1];
}
