#include <stdio.h>
#include <stdlib.h>
#define N 100

int a[N];
int count;

void init(){
    count = 0;
}

int pop(){
    return a[--count];
}

void push(int v){
    a[count++] = v;
}

int main(void){
    char s[11];
    int i;
    int v1,v2;

    init();

    while( scanf("%s", s) != EOF) {

        if(s[0] == '+'){
            v1 = pop();
            v2 = pop();
            push(v2+v1);
        }

        else if(s[0] == '-'){
            v1 = pop();
            v2 = pop();
            push(v2-v1);
        }

        else if(s[0] == '*'){
            v1 = pop();
            v2 = pop();
            push(v2*v1);
        }

        else push(atoi(s));
    }

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

    return 0;
}
