#include <stdio.h>
#include <stdlib.h>
#define MAX 100

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

int c[MAX],top;

int main(){
	int x,x1,x2;
	char s[MAX];

	while(scanf("%s",s) != EOF){
		if(s[0] == '+'){
			x1 = pop();
			x2 = pop();
			x = x2 + x1;
			push(x);
		}
		else if(s[0] == '-'){
			x1 = pop();
			x2 = pop();
			x = x2 - x1;
			push(x);
		}
		else if(s[0] == '*'){
			x1 = pop();
			x2 = pop();
			x = x2 * x1;
			push(x);
		}
		else{
			x = atoi(s);
			push(x);
		}
	}
	printf("%d\n",c[top]);

	return 0;
}

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

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