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

#define SIZE (2000)
#define STACK_SIZE (100)

struct {
    const size_t size;
    unsigned int top;
    int *buf;
} typedef Stack;

bool isEmpty(Stack *stack);
bool isFull(Stack *stack);
void push(Stack *stack, int n);
int pop(Stack *stack);

bool isEmpty(Stack *stack){
    return stack->top == 0;
}

bool isFull(Stack *stack){
    return stack->top >= stack->size;
}

void push(Stack *stack, int n){
    if(isFull(stack)){
        exit(1);
    }
    stack->buf[stack->top] = n;
    stack->top++;
}

int pop(Stack *stack){
    if(isEmpty(stack)){
        exit(1);
    }
    stack->top--;
    return stack->buf[stack->top];
}


int main(void){
    int a, b;
    char s[SIZE];
    char *tok;
    int stack_buf[100];
    Stack stack = {100, 0, stack_buf};

    fgets(s, SIZE, stdin);

    tok = strtok(s, " ");
    push(&stack, atoi(tok));

    while((tok = strtok(NULL, " ")) != NULL){
        if(tok[0] == '+'){
            a = pop(&stack);
            b = pop(&stack);
            push(&stack, a+b);
        }else if(tok[0] == '-'){
            a = pop(&stack);
            b = pop(&stack);
            push(&stack, b-a);
        }else if(tok[0] == '*'){
            a = pop(&stack);
            b = pop(&stack);
            push(&stack, a*b);
        }else{
            push(&stack, atoi(tok));
        }
    }

    printf("%d\n", pop(&stack));

    return 0;
}
