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

#define MAX_SIZE 100

#define SUB '-'
#define ADD '+'
#define MUL '*'

typedef struct Stack
{
    int *list;
    int len;
} * Stack;

void initStack(Stack *);
void push(Stack, int);
int pop(Stack);

int main(void)
{
    Stack s;
    initStack(&s);

    char op;
    int n, c;

    c = scanf("%d", &n);
    while (c != EOF) {
        if (c) {
            push(s, n);
        } else {
            scanf(" %c", &op);
            switch (op) {
            case ADD:
                push(s, pop(s) + pop(s));
                break;
            case SUB:
                push(s, -pop(s) + pop(s));
                break;
            case MUL:
                push(s, pop(s) * pop(s));
            }
        }
        c = scanf("%d", &n);
    }
    printf("%d", pop(s));

    return 0;
}

void initStack(Stack *s)
{
    *s = (Stack) malloc(sizeof(struct Stack));
    (*s)->list = (int *) malloc(MAX_SIZE * sizeof(int));
    (*s)->len = 0;
}

void push(Stack s, int x)
{
    s->list[s->len++] = x;
}

int pop(Stack s)
{
    return s->list[--s->len];
}
