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

struct Stack
{
	int S[101];
	int top;
	int capacity;
};

typedef struct Stack *stack;

stack createStack()
{
	stack s;
	s = (stack)malloc(sizeof(struct Stack));
	s->top = -1;
	s->capacity = 100;
	return s;
}

int isFull(stack s)
{
	return s->top == s->capacity;
}

void push(stack s, int x)
{
	if (isFull(s))
		return;
	s->S[++s->top] = x;
}

int isEmpty(stack s)
{
	return s->top == -1;
}

int pop(stack s)
{
	if (isEmpty(s))
		return -1;
	return s->S[s->top--];
}

void solve(stack s)
{
	char s1[100];
	while (1)
	{
		if (scanf("%s", s1) == EOF)
			break;
		int a, b;
		switch (s1[0])
		{
		case '+':a = pop(s), b = pop(s), push(s, a + b); break;
		case '-':b = pop(s), a = pop(s), push(s, a - b); break;
		case '*':a = pop(s), b = pop(s), push(s, a * b); break;
		default:push(s, atoi(s1)); break;
		}
	}
	printf("%d\n", pop(s));
}

int main()
{
	stack s;
	s = createStack();
	solve(s);
}
