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

int top, a[1000];

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

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


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