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

int top = 0, MAX = 101;
int S[101] = {0};

int isEmpty();
int isFull();
void push(int x);
int pop();

int main() {
    int tmp = 0, x;
    char ch[11];
    
    while (scanf("%s", ch) != EOF) {
        if (ch[0] == '+') {                 // case '+'
            tmp = pop();
            push(pop() + tmp);
        } else if (ch[0] == '-') {          // case '-'
            tmp = pop();
            push(pop() - tmp);
        } else if (ch[0] == '*') {          // case '*'
            tmp = pop();
            push(pop() * tmp);
        } else {                            // case "operand"
            x = atoi(ch);
            push(x);
        }
    }
    printf("%d\n", S[1]);
    return 0;
}

int isEmpty() {
    return (top == 0);
}

int isFull() {
    return (top >= MAX - 1);
}

void push(int x) {
    if (isFull()) {exit(1);}
    top++;
    S[top] = x;
    return;
}

int pop() {
    if (isEmpty()) {exit(1);}
    top--;
    return S[top+1];
}
