#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>

#define MAX 200

//char型をint型に変換し、seisuに返す
int Ihenkan(char stack[][MAX][MAX], int n)
{
	int kariseisu;

	kariseisu = atoi(stack[0][n]);

	return kariseisu;
}

//計算用関数
int keisan(char enz[], int seisu[], int Scount, int Ecount)
{
	int i = Scount - 1;

	
			switch (enz[Ecount]) {
			case '+':
				seisu[i - 1] = seisu[i - 1] + seisu[i];
				break;

			case '-':
				seisu[i - 1] = seisu[i - 1] - seisu[i];
				break;

			case '*':
				seisu[i - 1] = seisu[i - 1] * seisu[i];
				break;
			}

	return seisu[i - 1];
}

int main(void)
{
	int i = 0, j = 0, k = 0, n = 0, c = 0;
	char stack[MAX][MAX];
	int seisu[MAX];
	char enz[MAX];
	int Ecount = 0, answer = 0, Scount = 0;


	// スタックの計算式をため、演算子と整数で分けてカウントする
	while(1){

		scanf("%c", &stack[n][i]);

		if (stack[n][i] == '\n') {
			break;
		}

		if ((stack[n][i] >= '0') && (stack[n][i] <= '9')) {
			seisu[j] = Ihenkan(stack, n);
			i++;
		}
		
		else {
			if (stack[n][i] == ' ') {
				if ((stack[n][i - 1] >= '0') && (stack[n][i - 1] <= '9')) {
					Scount++;
					j++;
					i = 0;
				}
				n++;
				
				continue;
			}

			enz[k] = stack[n][i];
			seisu[j - 2] = keisan(enz, seisu, Scount, Ecount);
			k++;
			j--;
			Scount--;
			Ecount++; 
			}
		}
		
	answer = seisu[j - 1];

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

	return 0;	

}
