#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define buf 1001

int a,b,top,S[buf];

void push(int x);
int pop(void);
int main(void){
	int a,b,y=0,top=0;
	char s[buf],*line;

	fgets(s,sizeof(s),stdin);
	line=strtok(s," ");
	sscanf(line,"%d",&y);
	push(y);
	for( ; ; ){
		line=strtok(NULL," ");
		if(line==NULL)
			break;
		if(*line=='+'){
			b=pop();
			a=pop();
			push(a+b);
		}
		else if(*line=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}		
		else if(*line=='*'){
			b=pop();
			a=pop();
			push(a*b);
		}
		else{
			sscanf(line,"%d",&y);
			push(y);
		}
	}
	printf("%d\n",S[1]);
	return 0;
}
void push(int x){
	S[++top]=x;
}
int pop(void){
	return S[top--];
}