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

int top;
int bottle[150];

void push(int u)
{
	top++;
	bottle[top] = u;
}

int pop(){

    top=top-1;
	
	return bottle[top+1];
	
}

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



return 0;
}

