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

int sum,N[1000];

void tum(int a)
{
    N[++sum]=a;
    
}

int num()
{
    sum--;
    
    return N[sum+1];
}


int main()
{
    int i,j;
    sum = 0;
    char n[100];
    while(scanf("%s",n)!=EOF)
    {
        if(n[0]=='+')
        {
            i=num();
            j=num();
            tum(i+j);
        }
	else if(n[0]=='-')
        {
            j=num();
            i=num();
            tum(i-j);
        }
	else if(n[0]=='*')
        {
            i=num();
            j=num();
            tum(i*j);
        }
	else
        {
            tum(atoi(n));
        }
        
        
    }
    printf("%d\n",num());
    
    return 0;
    
}


