#include<stdio.h>

int main(void)
{
    long A[100];
    int i=0,sw=0,num;
    char s;

    while(scanf("%c",&s)!=EOF)
    {
        //printf("scan %c\n",s);
        if(s=='\n') break;
        switch(s)
        {
            case '+': 
                //printf("input +\n");
                i-=2;
                A[i]=A[i]+A[i+1];
                //printf("A[%d]=%d\n",i,A[i]);
                break;
        
            case '-':
                //printf("input -\n");
                i-=2;
                A[i]=A[i]-A[i+1];
                //printf("A[%d]=%d\n",i,A[i]);
                break;
        
            case '*':
                //printf("input *\n");
                i-=2;
                A[i]=A[i]*A[i+1];
                //printf("A[%d]=%d\n",i,A[i]);
                break;
            
            case '/':
                //printf("input /\n");
                i-=2;
                A[i]=A[i]/A[i+1];
                //printf("A[%d]=%d\n",i,A[i]);
                break;

            case ' ':
                //printf("i++\n");
                i++;
                sw=0;
                break;

            default:
                num=s-'0';
                //printf("input number %d\n",num);
                if(sw)
                {
                    A[i]=A[i]*10+num;
                }else
                {
                    A[i]=num;
                    sw=1;
                }
                //printf("A[%d]=%d\n",i,A[i]);
                break;
        }       
    }
    printf("%d\n",A[0]);

    return 0;

}
