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

typedef struct{
    int value[105];
    int top;
}stack;

void getValue(stack *, int *, int *);
int isEmpty(stack *);
void push(stack *, int);
int pop(stack *);

int main(){
    char s[100];
    stack polish = { .top = 0 };
    int a, b, res;
    while(scanf("%s", s) != EOF){
        if (s[0] == '+'){
            getValue(&polish, &a, &b);
            res = a + b;
            push(&polish, res);
        } 
        else if (s[0] == '-'){
            getValue(&polish, &a, &b);
            res = a - b;
            push(&polish, res);
        }
        else if (s[0] == '*'){
            getValue(&polish, &a, &b);
            res = a * b;
            push(&polish, res);
        } 
        else {
            int x = atoi(s);
            push(&polish, x);
        }
    }
    int result = pop(&polish);
    printf("%d\n", result);
    return 0;
}

void getValue(stack *source, int *bottom, int *top){
    *top = pop(source);
    *bottom = pop(source);
}

int isEmpty(stack *check) {
    if (check->top == 0) return 1;
    return 0;
}

void push(stack *pushTo, int source) {
    pushTo->value[++pushTo->top] = source;
}

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