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

struct node {
    int num;
    struct node * next;
};

static struct node *head=NULL;

struct node * create (int, struct node *);
void push (int);
int pop ();
void print_head ();

int main (void) {
    char ch;
    int num;

    for (;;) {
        scanf ("%c", &ch);
        if (ch>='0' && ch<='9') {
            ungetc (ch, stdin);
            scanf ("%d", &num);
            push (num);
        }
        else if (ch=='+') push(pop()+pop());
        else if (ch=='-') {
            int a = pop();
            int b = pop();
            push (b-a);
        } else if (ch=='*') push(pop()*pop());
        else if (ch=='\n') break;
        // print_head ();
    }

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

    return 0;
}

struct node * create (int num, struct node *next) {
    struct node * new;
    new = (struct node *) malloc (sizeof(struct node));
    new -> num = num;
    new -> next = next;
    return new;
}

void push (int num) {
    head = create (num, head);
}

int pop () {
    int num = head->num;
    struct node * t = head->next;
    free(head);
    head = t;
    return num;
}

void print_head () {
    struct node *t=head;
    for (;t!=NULL;t=t->next) printf ("%d ", t->num);
    printf ("\n");
}

