#include<stdio.h>
#define SIZE 200

int index=0;
int stack[SIZE];

void push(int n){
	stack[index++]=n;
}

int pop(){
	return stack[--index];
}

int main(void){
	//index=0;
	char op,dammy;
	
	while(scanf("%c",&op)!=EOF){
		scanf("%c",&dammy);
		if('0'<=op && op<='9'){
			push(op-'0');
		}else{
			int b=pop();
			int a=pop();
			switch(op){
				case '+':
					push(a+b);
					break;
				case '-':
					push(a-b);
					break;
				case '*':
					push(a*b);
					break;
				default:
					break;
			}
		}
	}
	printf("%d\n",pop());
	return 0;
}