#include<stdio.h>
#include<stdlib.h>
int main(void){
    int x=0,y=0,answer,i=0,z[100]={},j=0,count=0;
    char a[100];
    while(scanf("%s",a)==1){
        if(a[i]=='+'){
            answer=z[j-2]+z[j-1];
            z[j-2]=answer;
            j=j-1;
        }
        else if(a[i]=='-'){
            answer=z[j-2]-z[j-1];
            z[j-2]=answer;
            j=j-1;
        }
        else if(a[i]=='*'){
            answer=z[j-2]*z[j-1];
            z[j-2]=answer;
            j=j-1;
        }
        else{
             x=atoi(a+i);
             z[j]=x;
             j++;
        }
    }
    printf("%d\n",answer);   
    return 0;
}
