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

int top, s[1000];

void push(int x)
{
    top++;
    s[top] = x;
}

int pop()
{
    top--;
    return s[top + 1];
}

int main()
{
    int a, b;
    top = 0;
    char inputstring[100];

    while (scanf("%s", inputstring) != EOF)
    {
        if (inputstring[0] == '+')
        {
            a = pop();
            b = pop();
            push(a + b);
        } else if (inputstring[0] == '-')
        {
            b = pop();
            a = pop();
            push(a - b);
        } else if (inputstring[0] == '*')
        {
            a = pop();
            b = pop();
            push(a * b);
        } else
        {
            push(atoi(inputstring));
        }
    }
    
    printf("%d\n", pop());
    return 0;
}
