#include <stdio.h>
#include <string.h>

static int stack[100];
static int sp;

void push(int d)
{
    stack[sp] = d;
    sp++;
}

int pop(void)
{
    int d;
    sp--;
    return stack[sp];
}

int main()
{
    char op[8];
    int op1;
    int op2;
    int value;

    sp = 0;
    while(scanf("%s", op) != EOF) {
        //fprintf(stderr, "%s\n", op);
        if(strpbrk(op, "+-/*") == NULL) {
            sscanf(op, "%d", &value);
            //fprintf(stderr, "push %d\n", value);
            push(value);
        } else {
            op1 = pop();
            op2 = pop();
            //fprintf(stderr, "%s\n", op);
            if(op[0] == '+') {
                //fprintf(stderr, "%d = %d + %d\n", op2+op1, op2, op1);
                push(op2+op1);
            } else if(op[0] == '-') {
                //fprintf(stderr, "%d = %d - %d\n", op2-op1, op2, op1);
                push(op2-op1);
            } else if(op[0] == '/') {
                //fprintf(stderr, "%d = %d / %d\n", op2/op1, op2, op1);
                push(op2/op1);
            } else if(op[0] == '*') {
                //fprintf(stderr, "%d = %d * %d\n", op2*op1, op2, op1);
                push(op2*op1);
            }
        }
    }

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

    return 0;
}
