#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main()
{
    char a[100000001];
    int  b[10]={0}, i=0, ch;
    while(1){
        scanf("%s", &a);
        if(a[0] == '+'){
            b[i-2] = b[i-2] + b[i-1];
            i = i-1;
        } else if(a[0] == '-'){
            b[i-2] = b[i-2] - b[i-1];
            i = i-1;
        }  else if(a[0] == '*'){
            b[i-2] = b[i-2] * b[i-1];
            i = i-1;
        } else if(isdigit(a[0])){
            b[i] = atoi(a);
            i++;
        }
        ch = getchar();
        if(ch == '\n'){
            printf("%d\n", b[i-1]);
            break;
        }
    }
    return 0;
}