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

int stack[200];
int top = 0;

void push(int);
int pop();

int main() {
    char input[4];
    int a, b;

    while (scanf("%s", input) != EOF) {
        if (input[0] == '+') {
            push(pop() + pop());
            continue;
        }
        if (input[0] == '-') {
            a = pop();
            b = pop();
            push(b - a);
            continue;
        }
        if(input[0] == '*') {
            push(pop() * pop());
            continue;
        }
        push(atoi(input));
    }
    printf("%d\n", pop());
}

void push(int n) {
    stack[top++] = n;
}

int pop() {
    return stack[--top];
}

