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

#define MAX 101

typedef struct {
    int array[101]; // 0番目は使わない
    int top; // 常に要素数に一致
} Stack;

Stack S;

void initialize(void) {
    S.top = 0;
}

int isEmpty(void) {
    return S.top == 0;
}

int isFull(void) {
    return S.top >= MAX - 1;
}

void push(int x) {
    if (isFull()) {
        printf("Stack overflow\n");
        exit(0);
    } else {
        S.top++;
        S.array[S.top] = x;
    }
}

int pop() {
    if (isEmpty()) {
        printf("Stack underflow\n");
        exit(0);
    } else {
        S.top--;
        return S.array[S.top+1];
    }
}

int main(void) {
    int x;
    char s[100];
    initialize();
    while( scanf("%s", s) != EOF ) {
        if ( s[0] == '+' ) {
            int y = pop();
            int x = pop();
            push(x + y);
        } else if ( s[0] == '-' ) {
            int y = pop();
            int x = pop();
            push(x - y);
        } else if ( s[0] == '*' ) {
            int y = pop();
            int x = pop();
            push(x * y);
        } else  {
            x = atoi(s);
            push(x);
        }
    }
    printf("%d\n", pop());
    return 0;
}

