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

int stack[128];
int size;

void push(int x)
{
    stack[size] = x;
    size++;
}

int top(void)
{
    return (stack[size - 1]);
}

void pop(void)
{
    size--;
}

int main(void)
{
    char s[128];
    int a, b;
    int tmp;

    while (scanf("%s", s) != EOF){
        if (isdigit(s[0])){
            tmp = atoi(s);
        }
        else {
            b = top();
            pop();
            a = top();
            pop();
            switch (s[0]){
                case '+': tmp = a + b; break;
                case '-': tmp = a - b; break;
                case '*': tmp = a * b; break;
            }
        }
        push(tmp);
    }

    printf("%d\n", top());

    return (0);
}