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

 
int top, S[101];
 
void push(int x)
{

    S[++top] = x;
}
 
int pop()
{
    top--;

    return S[top+1];
}
 
int main(){
    int a,b;
    char t[100];
     
    while(scanf("%s", t) != EOF){
        if(t[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
        }else if(t[0] == '-'){
            b = pop();
            a = pop();
            push(a-b);
        }else if(t[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
        }else{
            push(atoi(t));
        }
    }
    printf("%d\n", pop());
    return 0;
}
