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

void push(int);
int pop(void);

int top=0, S[101];

int main(void)
{
	int x, y;
	char str[8];
	
	while ( scanf("%s",str) != EOF ) {
		switch ( str[0] ) {
		case '+':
			y = pop();
			x = pop();
			push(x+y);
			break;
		case '-':
			y = pop();
			x = pop();
			push(x-y);
			break;
		case '*':
			y = pop();
			x = pop();
			push(x*y);
			break;
		default:
			push( atoi(str) );
			break;
		}
	}
	printf("%d\n",S[top]);
	
	return 0;
}

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

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