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

int s[100];
int s_num=0;

void push(int x){
	s_num++;
	s[s_num] = x;
}

int pop(){
	s_num--;
	return s[s_num+1];
}

int main(){
	int p, q;
	char a[100];
	while(scanf("%s", a) != EOF){
		if(a[0]=='+'){
			p = pop();
			q = pop();
			push(q+p);
		}else if(a[0]=='-'){
			p = pop();
			q = pop();
			push(q-p);
		}else if(a[0]=='*'){
			p = pop();
			q = pop();
			push(q*p);
		}else if(a[0]=='/'){
			p = pop();
			q = pop();
			push(q/p);
		}else{
			push(atoi(a));
		}
	}

	printf("%d\n", pop());

	return 0;
}