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

	int top = -1;
	int push(int);
	int pop(void);
	char in[6];
	int stack[100],n,m;

int main(void){
	
	while(scanf("%s",in) != EOF){
	
	if(in[0] == '+'){
		
		n=pop();
		m=pop();
		push(m+n);
		
		}
		
	else if(in[0] == '-'){
		
		n=pop();
		m=pop();
		push(m-n);
		
		}
	
	else if(in[0] == '*'){
		
		n=pop();
		m=pop();
		push(m*n);
		
		}
	
	else{
		
		push(atoi(in));
		
		}
	
	}
	
	printf("%d\n",pop());
	
return 0;}


int push(int plus){
	
	top++;
	stack[top] = plus;
	
return 0;}


int pop(void){
	
	int num;
	num = stack[top];
	stack[top] = NULL;
	top--;
	
return num;}