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

int top, s[2000];

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

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

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

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

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

    return 0;
}
