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

void push(int);
int pop();
unsigned long top = 0;
char stack[100];

int main()
{
    unsigned long test_case,i=0;
  
    int temp,b,c,d;
   
    char a[100];
    for( ; ; )
    {
        int readScan = scanf("%s", &a);
        if(readScan == EOF)
        {
            break;
        }
        if(a != '+'&& a != '-' && a !='*')
        {
            temp = atoi(a);
            push(temp);
        }
        if(a == '+')
        {
            b = pop();
            c = pop();
            d = b+c;
            push(d);
        }
        if(a == '*')
        {
            b=pop();
            c=pop();
            d = b*c;
            push(d);
        }
        if(a == '-')
        {
            b=pop();
            c=pop();
            d = b-c;
            push(d);
        }
}
printf("%d\n",d);
return 0;
}

void push(int x)
{
    if(top==100)
        return;
    else
    {
        stack[++top]=x;
    }
}

int pop()
{
    int item;
    if(top == -1) // Checking Array is empty or not.
    {
    	return -1; 
    }
    item = stack[top];
    top -= 1; //	top = top - 1
    return item;
}
