#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_N 200

int top, S[MAX_N];

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

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


int main(void) {
    top = 0;
    char line[20];

    int a, b;
    while (scanf("%s", line) != EOF) {
        if (line[0] == '+') {
            a = pop();
            b = pop();
            push(b+a);
        } else if (line[0] == '-') {
            a = pop();
            b = pop();
            push(b-a);
        } else if (line[0] == '*') {
            a = pop();
            b = pop();
            push(b*a);
        } else {
            push(atoi(line));
        }
    }

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

    return 0;
}