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

#define MAX 199

int top;
long int S[MAX];

void initialize(){
    top=0;
}

int isEmpty(){
    return top==0;
}

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

void push(int x){
    if (isFull()){
        printf("error-full\n");
    }
    top++;
    S[top+1] = x;
}

int pop(){
    if(isEmpty()){
        printf("error-empty\n");
    }
    top--;
    return S[top+1];
}

int main(void){
    int i,j,a,b;
    char c[256];
    initialize();
    while(scanf("%s",c)!=EOF){
        if(c[0]=='+'){
            a=pop();
            b=pop();
            push(a+b);
        }
        else if(c[0]=='*'){
            a=pop();
            b=pop();
            push(a*b);
        }
        else if(c[0]=='-'){
            a=pop();
            b=pop();
            push(b-a);
        }
        else{
            push(atoi(c));
        }
    }
    printf("%d\n",pop());

    return 0;
}