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

int top, Stack[1024];

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

int pop(){
    top--;
    return Stack[top+1];
}

int main(){
    int a, b, res;
    top = 0;
    char input[100];

    while( scanf("%s", input) != EOF ){
        if(input[0] == '+'){
            a = pop();
            b = pop();
            push(a + b);
        }else if(input[0] == '-'){
            b = pop();
            a = pop();
            push(a - b);
        }else if(input[0] == '*'){
            a = pop();
            b = pop();
            push(a * b);
        }else{
            push( atoi(input) );
        }
    }

    printf("%d\n", pop());

    return 0;
}



