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

# define STACK_MAX 200 /* ???????????????????????§(100) + ?????????????????§(99) + 1 */

void push(value);
int pop();
int main(void);
bool isNum(char c);	
char* getOperand();

static	int st_stack_index = 0;
static	int st_stack[STACK_MAX];
static 	char st_Operand[STACK_MAX];

int main(void) {

	int value = 0;

	char* ope;
	int ope1;
	int ope2;

	while ((ope = getOperand()) != NULL) {

		if (*ope == ' ') {
			continue;
		}

		/* ?????????????????°?????? */
		if (isNum(*ope)) {
			/*printf("%s ", ope);*/
			push(atoi(ope));
		}
		else { /* ??°?????§???????????°????????? */
			ope1 = pop();
			ope2 = pop();
			/*printf("%s ", ope);*/

			switch (*ope) {
			case '+':
			{
				value = ope1 + ope2;
			}
			break;
			case '*':
			{
				value = ope1 * ope2;
			}
			break;
			case '-':
			{
				value = ope2 - ope1;
			}
			break;
			default:
			{
				return -1;
			}
			}
			/* ?¨????????????????????????????????´? */
			push(value);
		}
	}

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

	return 0;
}

bool isNum(char c)
{
	if (isdigit(c) != 0) {
		return true;
	}
	else {
		return false;
	}
}

/* ?¨??????\???????????????????????????????????????????????§?????????????????? */
char* getOperand()
{
#if 0
	static char* question[] = { "1", "2", "+", "3", "4", "-", "*", NULL };
	//char question[] = "10 5 + 3 *";
	static int question_index = 0;

	return question[question_index++];
#else
	
#endif
	if (scanf("%c", st_Operand) != EOF/*EOF??§??????*/) {
		if (*st_Operand != '\n') {
			return st_Operand;
		}
	}
	return NULL;
}

void push(value) {

	st_stack_index++;
	st_stack[st_stack_index] = value;

}

int pop() {

	int p;

	p = st_stack[st_stack_index];

	st_stack_index--;

	return p;
}