#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 str[100];

    while (scanf("%s", str) != EOF) {
        switch (str[0]) {
        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));
            break;
        default:
            push(s, atoi(str));
        }
    }
    printf("%d\n", 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];
}
