#include<stdio.h>
#include<ctype.h>
#define max 100
int stack[max];
int top=-1;
void push(int val){
    stack[++top]=val;
}
int pop(){
    return stack[top--];
}
int main(){
    char postfix[max];
    fgets(postfix,max,stdin);
    int i=0;
    while (postfix[i] != '\0') {

        // Build multi-digit number
        if (isdigit(postfix[i])) {
            num = 0;
            while (isdigit(postfix[i])) {
                num = num * 10 + (postfix[i] - '0');
                i++;
            }
            push(num);
        }

        // Operator
        else if (postfix[i] == '+' || postfix[i] == '-' ||
                 postfix[i] == '*' || postfix[i] == '/') {

            int b = pop();
            int a = pop();

            switch (postfix[i]) {
                case '+': push(a + b); break;
                case '-': push(a - b); break;
                case '*': push(a * b); break;
                case '/': push(a / b); break;
            }
        }
        i++;
    }

    printf("%d",pop());
    return 0;
    
}