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

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

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

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

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

    char op;
    int n, res, c, x, y;

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

    return 0;
}

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

void push(Stack s, int x)
{
    if (s->len == s->size) {
        if (s->size)
            s->size *= 2;
        else
            s->size = 1;
        int *tmp = (int *) malloc(s->size * sizeof(int));
        if (s->list) {
            memcpy(tmp, s->list, s->len * sizeof(int));
            free(s->list);
        }
        s->list = tmp;
    }
    s->list[s->len++] = x;
}

int pop(Stack s)
{
    int tmp = s->list[--s->len];
    if (s->len <= s->size / 4) {
        s->size /= 2;
        int *tmp = (int *) malloc(s->len * sizeof(int));
        memcpy(tmp, s->list, s->len * sizeof(int));
        free(s->list);
        s->list = tmp;
    }
    return tmp;
}
