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

int s2i(char a[7]){
    int i,k=0;
    for(i=0;a[i]!='\0';i++){
        k = k*10+(a[i]-'0');
    }
    return k;
}

int main(void){
    int a[128],b,c;
    int top=2,n;
    char str[7];
    scanf("%d",&a[0]);
    scanf("%d",&a[1]);
    while(scanf("%s",str)!=EOF){
        if(strcmp(str,"+")==0){
            b = a[top-1];
            c = a[top-2];
            a[top-2] = b+c;
            top--;
        }else if(strcmp(str,"-")==0){
            b = a[top-2];
            c = a[top-1];
            a[top-2] = b-c;
            top--;
        }else if(strcmp(str,"*")==0){
            b = a[top-1];
            c = a[top-2];
            a[top-2] = b*c;
            top--;
        }else{
            a[top] = s2i(str);
            top++;
        }
    }
    printf("%d\n",a[0]);
}
