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

int myTop = 0;
int myData[1000] = { 0 };
void push(int x)
{
	++myTop;
	myData[myTop] = x;
}
void pop()
{
	--myTop;
}
int top()
{
	int nTemp = myData[myTop];
	return nTemp;
}

int main()
{
	char chIn[1000] = { '\0' };
	int nTemp = 0;
	int na = 0, nb = 0;

	while (scanf("%s", chIn))
	{
		if (chIn[0] - '0' <= 9 && chIn[0] - '0' >= 0)
		{
			nTemp = atoi(chIn);
			push(nTemp);
		}
		else
		{
			nb = top();
			pop();
			na = top();
			pop();
			switch (chIn[0])
			{
			case '-':
				push(na - nb);
				break;
			case '+':
				push(na + nb);
				break;
			case '*':
				push(na * nb);
				break;
			}
		}
	}
	printf("%d\n", top());
	return 0;
}
