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

#define MAX 100

int n[MAX], top = 0; 

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

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

int main(void)
{
    int x, y;
    char str[10];
    
    while (scanf("%s", str) != EOF) {
        switch (str[0]) {
            case '+':
                y = pop();
                x = pop();
                push(x + y);
                break;
            case '-':
                y = pop();
                x = pop();
                push(x - y);
                break;
            case '*':
                y = pop();
                x = pop();
                push(x * y);
                break;
            default:
                push(atoi(str));
                break;
        }
    }
    printf("%d\n", n[0]);
    return 0;
}