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

#define STACK_SIZE 100

int pop(int *stack, int *tail) 
{
    return stack[(*tail)--]; 
}

void push(int push_operand, int *stack, int *tail)
{
    stack[++(*tail)] = push_operand; 
}

int digitsNum(int num)
{
    int digit = 0, tmp = num;

    while(tmp != 0) {
        tmp = tmp / 10;
        ++digit;
    }

    return digit;
}

void calc(char *operand, int *stack, int *tail) 
{
    int left_operand, right_operand;

    if(!isdigit(operand[0])) {    
        right_operand = pop(stack, tail);
        left_operand = pop(stack, tail);
        if(strcmp(operand, "+") == 0) {
            push(left_operand + right_operand, stack, tail);
        } else if(strcmp(operand, "-") == 0) {
            push(left_operand - right_operand, stack, tail);
        } else if(strcmp(operand, "*") == 0) {
            push(left_operand * right_operand, stack, tail);
        } 
    }else {
        push(atoi(operand), stack, tail); 
    }
}

int main(void)
{
    int tail = -1, stack[STACK_SIZE];
    char str[400], *operand;

    fgets(str, sizeof(str), stdin);
    strtok(str, "\n\0");
    operand = strtok(str, " ");
    calc(operand, stack, &tail);
    while((operand = strtok(NULL, " ")) != NULL) {
        calc(operand, stack, &tail);
    }
    printf("%d\n", pop(stack, &tail));

    return 0;
}