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

int top, S[1000];
int MAX = 1000;

void initialize() {
    top = 0;
}

int isEmpty() {
    return top == 0;
}

int isFull() {
    return top >= MAX - 1;
}

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

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

int main(void){
    // Your code here!
    int a, b = 0;
    char s[1000];
    initialize();
    
    while( scanf("%s", s) != EOF) {
        if(s[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        } else if(s[0] == '-') {
            a = pop();
            b = pop();
            push(b-a);
        } else if(s[0] == '*') {
            a = pop();
            b = pop();
            push(a*b);
        } else{
            push(atoi(&s[0]));
        }
    }
    
    printf("%d\n", pop());
}

