#include <stdio.h>
#include <stdlib.h>
int main(void){
    int i=0,a[100];
    char s[2];
    for(;~scanf("%s",s);){
        switch(*s){
            case'+':i--;a[i-1]+=a[i];break;
            case'-':i--;a[i-1]-=a[i];break;
            case'*':i--;a[i-1]*=a[i];break;
            default:a[i++]=atoi(s);
            }
    }
    printf("%d\n",a[0]);
    return 0;
}

