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

void push( int );
int pop();
int top;//ポインタ
int keep[1000];//データ格納用配列

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

void push( int x ){
	keep[++top] = x;
}

int pop(){
	top--;
	return keep[top+1];
}


