#define LEN 105
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int numStack[LEN];
int top = 0;

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

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

int main() {
    char str[15];
    int a, b = 0;
    while (scanf("%s", str) != EOF) {
        if (str[0] == '+') {
            a = pop();//后操作数
            b = pop();
            push(a + b);
        }
        else if (str[0] == '-') {
            a = pop();//后操作数
            b = pop();
            push(b - a);
        }
        else if (str[0] == '*') {
            a = pop();//后操作数
            b = pop();           
            push(a * b);
        }
        else {
            push(atoi(str));
        }
    }
    printf("%d\n", pop());
    return 0;
}
