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

#define MAX 20

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

	seisu = atoi(stack);

	return seisu;
}

//計算用関数
int keisan(char enz[], int seisu[], int Ecount)
{
	int i = 0, j = 0, k = 0;

	for (j = 0; j < Ecount; j++){
			switch (enz[k]) {
			case '+':
				seisu[i] = seisu[i] + seisu[i + 1];
				break;

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

			i++;
			k++;
		}

	return seisu[i - 1];
}

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


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

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

		if ((stack[i] >= '0') && (stack[i] <= '9')) {
			seisu[j] = Ihenkan(stack, i);
			j++;
		}
		else {
			if (stack[i] == ' ') {
				continue;
			}
			enz[k] = stack[i];
			Ecount++;
			k++;
		}
	}
		
	answer = keisan(enz, seisu, Ecount);
	printf("%d", answer);

	return 0;	

}
