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

typedef struct node *link;
struct node { 
    int item;
    link next;
};
static link head;

void Stackinit (int maxN) { head = NULL; }
int Stackenpty (void) { return head == NULL; }
int Stackpop (void) {
    int item = head->item;
    link t = head->next;
    free(head);
    head = t;
    return item;
}
link NEW(int item, link next) {
    link x = malloc(sizeof *x);
    x->item = item;
    x->next = next;
    return x;
}
void Stackpush (int item) {
    head = NEW(item, head);
}

int main(void) {
    int result = 0, x1, x2;
    char s[11];
    Stackinit(1000);
    while (scanf(" %10s", s) != EOF) {
        if (s[0] == '+') {
            x1 = Stackpop();
            x2 = Stackpop();
            Stackpush(x2 + x1);
        } else if (s[0] == '-') {
            x1 = Stackpop();
            x2 = Stackpop();
            Stackpush(x2 - x1);
        } else if (s[0] == '*') {
            x1 = Stackpop();
            x2 = Stackpop();
            Stackpush(x2 * x1);
        } else if (isdigit(s[0])){
            x1 = (int) strtol(s, NULL, 10);
            Stackpush(x1);
        } else break;
    }
    result = Stackpop();
    printf("%d\n", result);
    return 0;
}