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

#define STACK_SIZE 200

struct Stack {
    int operand[STACK_SIZE];
    int top;
};

static void pushOperand(struct Stack* s, int operand) {
    s->operand[s->top] = operand;
    s->top++;
    return;
}

static int popOperand(struct Stack* s) {
    s->top--;
    return s->operand[s->top];
}

int main(int argc, char* argv[]) {
    struct Stack stack;
    char buf[100];

    memset(&stack, 0x00, sizeof(stack));

    while ( scanf("%s", buf) != EOF ) {
        if ( buf[0] == '+' ) {
            int op1, op2, result;
            op1 = popOperand(&stack);
            op2 = popOperand(&stack);
            result = op2 + op1;
            pushOperand(&stack, result);
        } else if ( buf[0] == '-' ) {
            int op1, op2, result;
            op1 = popOperand(&stack);
            op2 = popOperand(&stack);
            result = op2 - op1;
            pushOperand(&stack, result);
        } else if ( buf[0] == '*' ) {
            int op1, op2, result;
            op1 = popOperand(&stack);
            op2 = popOperand(&stack);
            result = op2 * op1;
            pushOperand(&stack, result);
        } else {
            int op = atoi(buf);
            pushOperand(&stack, op);
        }
    }

    int result = popOperand(&stack);

    printf("%d\n", result);
    
    return 0;
}



