/*
 * reverse porland
 * stack
 *
 *
 */
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define MAX 100
int stack[MAX+1],p;
void push(int);
int pop(void);
int isempty(void);

int main(){

    int before,after,j;
    char c[100];

    while(scanf("%s",c) != EOF){
        if(!strcmp(c,"+")){
            after = pop();
            before = pop();
            push(after + before);

        }else if(!strcmp(c,"-")){

            after = pop();
            before = pop(); 
            push(before - after);

        }else if(!strcmp(c,"*")){

            push(pop()*pop());

        }else if(!strcmp(c,"/")){

            after = pop();
            before = pop();

            push(before/after);
        }else{
            push(atoi(c));
        }

    }

    printf("%d\n",pop());
    return 0;
}

void push(int x){
    stack[p++]=x;
}

int pop(){
    if(isempty()){
        return stack[--p];
    }
    return 0;
}


int isempty(){
    if(stack[p]!='null'){
        return 1;
    }else{
        return 0;
    }
}

