#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct stack
{
    int data[105];
    int top;
};
void stack_init(struct stack *s)
{
    s->top = 0;
}
void stack_push(struct stack *s, int d)
{
    s->data[s->top++] = d;
}
int stack_pop(struct stack *s)
{
    return s->data[--s->top];
}
int main()
{
    struct stack s;
    char ch[10];
    int a, b;
    stack_init(&s);
    while (scanf("%s", ch) != EOF)
    {
        if (!strcmp(ch, "+"))
        {
            b = stack_pop(&s);
            a = stack_pop(&s);
            stack_push(&s, a + b);
        }
        else if (!strcmp(ch, "-"))
        {
            b = stack_pop(&s);
            a = stack_pop(&s);
            stack_push(&s, a - b);
        }
        else if (!strcmp(ch, "*"))
        {
            b = stack_pop(&s);
            a = stack_pop(&s);
            stack_push(&s, a * b);
        }
        else
            stack_push(&s, atoi(ch));
    }
    printf("%d\n", stack_pop(&s));
}

