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

int Stack[1000];
int top;

void push(int x){
    Stack[++top] = x;
}

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

int main(void){
    top = 0;
    char input[100];
    int a, b;

    while (scanf("%s", input)!= EOF){
        switch (input[0]){
            case '+':
                b = pop();
                a = pop();
                push(a+b);
                break;
            case '-':
                b = pop();
                a = pop();
                push(a-b);
                break;
            case '*':
                b = pop();
                a = pop();
                push (a*b);
                break;
            default:
                push(atoi(input));
                break;
        }
    }

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

    return 0;
}