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

int top, S[1000];

void init_stack()
{
	top = -1;
}

void push(int v)
{
	S[++top] = v;
}

int pop()
{
	return S[top--];
}

int do_op(int a, int b, char op)
{
	int r = 0;
	
	switch (op) {
	case '+':
		r = a + b;
		break;
	case '-':
		r = a - b;
		break;
	case '*':
		r = a * b;
		break;
	}
	
	return r;
}

int main(int argc, char *argv[]) 
{
	char a[100];
	int op1, op2;

	init_stack();
	while (scanf("%s", a) != EOF) {
		if (isdigit(*a)) {
			push(*a - '0');
		} else {
			op2 = pop();
			op1 = pop();
			push(do_op(op1, op2, *a));
		} 
	}
	
	printf("%d\n", pop());
	
	return 0;
}
