#include <stdio.h>
#include <stdlib.h>
/**
 * Push
 * @param[in, out] stack array
 * @param[in] data value to be push onto array
 * @param[in, out] sp stack pointer
 * @param[in] n max num of elements in array
 * @retval >= 1 num of elements in array
 * @retval 0 fail push in array
 */

int Push(int *stack, int data, int *sp, size_t n){
    if (*sp < n) {
        stack[(*sp)++] = data;
        return *sp;
    } else {
        return 0;
    }
}

/**
 * pop
 * @param[in, out] stack array
 * @param[in, out] sp stack pointer
 * @return value poped
 */
int Pop(int *stack, int *sp){
    if (*sp > 0) return stack[--(*sp)];
    else return 0;
}

int main(){
    int data, stack[100], sp = 0, a, b, x;
    char s[100];
    
    while (scanf("%s", s) != EOF) {
//        if (s[0]== EOF ) break;
        if (s[0] == '+') a = Pop(stack, &sp), b = Pop(stack, &sp), Push(stack, a + b, &sp, 100);
        else if (s[0] == '-') a = Pop(stack, &sp), b = Pop(stack, &sp), Push(stack, a - b, &sp, 100);
        else if (s[0] == '*') a = Pop(stack, &sp), b = Pop(stack, &sp), Push(stack, a * b, &sp, 100);
        else Push(stack, atoi(s), &sp, 100);
        
    }
    printf("%d\n", Pop(stack, &sp));
    return 0;
}