#include <stdio.h>
#include <stdlib.h>
#define N 100
#define L 1000
int st[N];
int point_st;



void stack(int n);
int pop();

int main(void){

int i=0,j,n,a,b;
char c[L];
char d[12];

	scanf("%[0-9 +*-]",c);

	while(c[i] != '\0'){
 	
		switch(c[i]){

			case ' ':
			break;

			case '+':
			b=pop();
			a=pop();
			stack(a+b);
			break;

			case '-':
			b=pop();
			a=pop();
			stack(a-b);
			break;

			case '*':
			b=pop();
			a=pop();
			stack(a*b);
			break;

			default:
			a=0;
			while(c[i]<='9' && c[i]>='0'){
				a=a*10+c[i]-'0';
				i++;
			}
			stack(a);

			break;

		}
		i++;
 	}

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

 }


void stack(int n){

	st[point_st] = n;
	point_st++;

	return;
}

int pop(){

	point_st--;
	return st[point_st];
}