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

typedef struct tagItem Item;
struct tagItem {
    int value;
    Item *prev;
};

void push(Item **sp, int value)
{
    //printf("push %d\n", value);
    Item *item = (Item *)malloc(sizeof(Item));
    item->value = value;
    item->prev = *sp;
    *sp = item;
}

int pop(Item **sp)
{
    Item *item = *sp;
    if (item != NULL) {
        int value = item->value;
        *sp = item->prev;
        free(item);
        //printf("pop %d\n", value);
        return value;
    }
    //printf("pop error\n");
    return 0;
}

int main(void)
{
    Item *stack = NULL;
    char s[1000];
    char *tk;
    int v1, v2;
    fgets(s, 999, stdin);
    s[strlen(s) - 1] = '\0';

    tk = strtok(s, " ");
    while (tk != NULL) {
        //printf("tk=[%s]\n", tk);
        if (strcmp(tk, "+") == 0) {
            v2 = pop(&stack);
            v1 = pop(&stack);
            push(&stack, v1 + v2);
        }
        else if (strcmp(tk, "-") == 0) {
            v2 = pop(&stack);
            v1 = pop(&stack);
            push(&stack, v1 - v2);
        }
        else if (strcmp(tk, "*") == 0) {
            v2 = pop(&stack);
            v1 = pop(&stack);
            push(&stack, v1 * v2);
        }
        else if (strcmp(tk, "/") == 0) {
            v2 = pop(&stack);
            v1 = pop(&stack);
            push(&stack, v1 / v2);
        }
        else {
            push(&stack, atoi(tk));
        }
        tk = strtok(NULL," .");
    }
    v1 = pop(&stack);
    printf("%d\n", v1);

    return 0;
}
