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


int main(){
    
    char s[10];//入力用変数
    int A[102];//数値入力用配列
    int point=0;

    while(scanf("%s",s)!=EOF){
        if(s[0]=='+'){
            A[point-1]+=A[point];
            point--;
        }else if(s[0]=='-'){
            A[point-1]-=A[point];
            point--;
        }else if(s[0]=='*'){
            A[point-1]*=A[point];
            point--;
        }else{
            point++;
            A[point]=atoi(s);
        }
    }

    printf("%d\n",A[1]);
}
