#include <stdio.h>

void main()
{
    char a;
    int stk[100],cnt = -1;
    while((a = getchar())!=EOF)
    {
        //printf("%c\n",a);
        if('0' < a && a < '9'){
            cnt += 1;
            stk[cnt] = a - '0';
            //printf("stk = %d",stk[cnt]);
        }else {
            switch(a){
                case '+':
                    stk[cnt-1] = stk[cnt-1] + stk[cnt];
                    cnt -=1;
                    break;
                case '-':
                    stk[cnt-1] = stk[cnt-1] - stk[cnt];
                    cnt -=1;
                    break;
                case '/':
                    stk[cnt-1] = stk[cnt-1] * stk[cnt];
                    cnt -=1;
                    break;
                case '*':
                    stk[cnt-1] = stk[cnt-1] / stk[cnt];
                    cnt -=1;
                    break;
                default:
                    //printf("space\n");
                    break;
            }
        }
    }
    printf("%d\n",stk[cnt]);
}
