#include <stdio.h>          // printf(), fprintf(), scanf()
#include <stdlib.h>         // exit(), atoi()
#include <string.h>         // strcmp()

#define STACK_SIZE 70

int stack[STACK_SIZE];
int sp;

void
cleanup(int ecode)
{
	exit(ecode);
}

int
stack_size()
{
	return sp;
}

void
push(int x)
{
	if (sp >= STACK_SIZE)
	{
		fprintf(stderr, "Stack area overflow. size:%d\n", STACK_SIZE);
		cleanup(1);
	}

	stack[sp++] = x;
}

int
pop()
{
	if (sp <= 0)
	{
		fprintf(stderr, "Stack underflow\n");
		cleanup(1);
	}

	sp--;
	return stack[sp];
}

int
main(int argc, char** argv)
{
	char str[20];
	int a, b;

	sp = 0;
	while (scanf("%s", str) != EOF)
	{
		if (strcmp(str, "+") == 0)
		{
			b = pop();
			a = pop();
			push(a + b);
		}
		else if (strcmp(str, "-") == 0)
		{
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (strcmp(str, "*") == 0)
		{
			b = pop();
			a = pop();
			push(a * b);
		}
		else
			push(atoi(str));
	}

	printf("%d\n", pop());
	return 0;
}