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

#define MAX_SIZE 100

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

int S[MAX_SIZE];
int top;

void push(int);
int pop();

int main(void)
{
    top = 0;

    char str[100];

    while (scanf("%s", str) != EOF) {
        switch (str[0]) {
        case ADD:
            push(pop() + pop());
            break;
        case SUB:
            push(-pop() + pop());
            break;
        case MUL:
            push(pop() * pop());
            break;
        default:
            push(atoi(str));
        }
    }
    printf("%d\n", pop());

    return 0;
}

void push(int x)
{
    S[top++] = x;
}

int pop()
{
    return S[--top];
}
