#include <stdio.h>
#define STACK_SIZE 1000

int stack[STACK_SIZE];
int stack_size = 0;

int pop()
{
	if (stack_size <= 0) return 0;
	return stack[--stack_size];
}

int push(int a)
{
	stack[stack_size++] = a;
}

int calc(char *s)
{
	int a, b, type;
	while (*s) {
		switch(*s) {
		case ' ':
			break;
		case '+':
			a = pop();
			b = pop();
			push(b+a);
			break;
		case '-':
			a = pop();
			b = pop();
			push(b-a);
			break;
		case '*':
			a = pop();
			b = pop();
			push(b*a);
			break;

		default:
			push(*s - '0');
		}
		s++;
	}
	return pop();
}

int main()
{
	char s[STACK_SIZE];
	scanf("%[^\n]*s", s);
	printf("%d\n", calc(s));
	return 0;
}