#include<stdio.h>
#define SIZE 100
int stack[SIZE];
int n=0;

void push(int x){
    if(n<SIZE){
        n++;
        stack[n]=x;
    }
}
int pop(){
   return stack[--n]; 
}

int main(void){
    char c;
    int x,a,b;
    
    while((c=getchar())!=EOF){
        if(isdigit(c)){
            ungetc(c,stdin);
            scanf("%d",&x);
            push(x);
        }else{
            switch(c){
                case '+':
                push(pop()+pop());
                break;
                case '-':
                b=pop();
                a=pop();
                push(a-b);
                break;
                case '*':
                push(a*b);
                break;
                case ' ':
                break;
                case '\n':
                printf("%d\n",pop());
                break;
                default:
                break;
            }
        }
    }
}
