#include <stdio.h>
#include <malloc.h>
#include <assert.h>
#include <ctype.h>

typedef struct StkDat {
    int key;
    struct StkDat *next;
} StkDat;
typedef struct Stack {
    size_t len;
    StkDat *top;
} Stack;
#define stack_isempty(s) ((s)->top == NULL ? 1 : 0)

void stack_init(Stack *stk_hdr) {
    stk_hdr->len = 0;
    stk_hdr->top = NULL;
}
int stack_pop(Stack *stk_hdr) {
    assert(stk_hdr->len != 0);
    stk_hdr->len--;
    int key = stk_hdr->top->key;
    StkDat *old_head = stk_hdr->top;
    stk_hdr->top = stk_hdr->top->next;
    free(old_head);
    return key;
}

void stack_push(Stack *stk_hdr, const int key) {
    StkDat *new_dat = (StkDat *)malloc(sizeof(StkDat));
    new_dat->key = key;
    new_dat->next = stk_hdr->top;
    stk_hdr->top = new_dat;
    stk_hdr->len++;
}

int main() {
    Stack stk;
    stack_init(&stk);
    char c;
    while(~scanf(" %c", &c)) {
        if(isdigit(c)) {
            stack_push(&stk, c - '0');
        } else {
            int y = stack_pop(&stk);
            int x = stack_pop(&stk);
            switch(c) {
            case '+':
                stack_push(&stk, x + y);
                break;
            case '-':
                stack_push(&stk, x - y);
                break;
            case '*':
                stack_push(&stk, x * y);
                break;
            default:
                break;
            }
        }
    }
    printf("%d\n", stack_pop(&stk));
    return 0;
}

