#include<stdio.h>
#include<stdlib.h>
            
int pop(void);
void push(int);
int stack[100],i=0;
            
int pop(void)
{
    return stack[--i];
}
            
void push(int num)
{
    stack[i++] = num;
}
int main()
{
    char c[100];
    int x,y;
    while( scanf("%s",c) != EOF )
    {
        if( c[0] == '+')
        {
            x = pop();
            y = pop();
            push(x+y);
        }
        else if( c[0] == '-' )
        {
            x = pop();
            y = pop();
            push(y-x);
        }
        else if( c[0] == '*' )
        {
            x = pop();
            y = pop();
            push(x*y);
        }
        else
        {
            push(atoi(c));
        }
    }
        printf("%d\n",stack[0]);
        return 0;
}
