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

#define MAX 100

void intiallize();
int isEmpty();
int isFull();
void push(int x);
int pop();

int top;
int a[MAX];

int main(){
	int x,a,b;
	char s[100];

	intiallize();

	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(s[0]=='-'){
			a=pop();
			b=pop();
			push(b-a);
		}else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			x=atoi(s);
			push(x);
		}
	}

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

	return 0;
}

void intiallize(){
	top=0;
}

int isEmpty(){
	if(top==0){
return 1;
}else return 0;
}

int isFull(){
	if(top>MAX-1){
         return 1;
}else return 0;
}

void push(int x){
	if(isFull()){
		exit(1);
	}
	top++;
	a[top]=x;
}

int pop(){
	if(isEmpty()){
		exit(2);
	}
	top--;
	return a[top+1];
}