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

#define MAXSTACKED 100
#define MAXOP 1000000

int g_cnt = 0;

void plus(int stack[]);
void minus(int stack[]);
void times(int stack[]);

int main(void)
{
    int stack[MAXSTACKED];

    char symbol[MAXOP];
    while (scanf("%s", symbol) != EOF) {
        if (symbol[0] == '+') {
            plus(stack);
        } else if (symbol[0] == '-') {
            minus(stack);
        } else if (symbol[0] == '*') {
            times(stack);
        } else {
            stack[g_cnt++] = atoi(symbol);
        }
/*        for (int i = 0; i < g_cnt; i++) {
            printf("%d ", stack[i]);
        }
        printf("\n");*/
    }

    printf("%d\n", stack[0]);

    return 0;
}

void plus(int stack[])
{
    int op1 = stack[--g_cnt];
    int op2 = stack[--g_cnt];
    stack[g_cnt++] = op1 + op2;
}

void minus(int stack[])
{
    int op2 = stack[--g_cnt];
    int op1 = stack[--g_cnt];
    stack[g_cnt++] = op1 - op2;
}

void times(int stack[])
{
    int op1 = stack[--g_cnt];
    int op2 = stack[--g_cnt];
    stack[g_cnt++] = op1 * op2;
}