#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdbool.h>

struct stack {
        size_t size;
        int in;
        int data[1];
};

static bool
isfull(struct stack *st)
{
        if (st->in >= st->size - 1)
                return true;

        return false;
}

static bool
isempty(struct stack *st)
{
        if (st->in == 0)
                return true;

        return false;
}

static int
push(struct stack *st, int x)
{
        if (isfull(st))
                return -1;

        st->data[st->in++] = x;

        return 0;
}

static int
pop(struct stack *st, int *x)
{
        if (isempty(st))
                return -1;

        st->in--;
        *x = st->data[st->in];

        return 0;
}

int
main(void)
{
        struct stack *st = malloc(sizeof(struct stack) + sizeof(int) * 200);
        st->in = 0;
        st->size = 200;

        char s[100];
        while (scanf("%s", s) != EOF) {
                int tmp;
                if (!ispunct(s[0])) {
                        tmp = strtol(s, NULL, 10);
                } else {
                        int x;
                        int y;
                        pop(st, &y);
                        pop(st, &x);
                        switch (s[0]) {
                        case '+':
                                tmp = x + y;
                                break;
                        case '-':
                                tmp = x - y;
                                break;
                        case '*':
                        default:
                                tmp = x * y;
                                break;
                        }
                }
                push(st, tmp);
        }

        int ans;
        pop(st, &ans);
        printf("%d\n", ans);

        return 0;
}


