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

#define Max 1000
int top = 0;

int isEmpty( ) {
	return top == 0;
}

int isFull( ) {
	return top >= Max -1;
}

void push(int stack[Max], int value) {
	stack[++top]  = value;
}

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

int main( ) {
	int N, i;
	int a, b;
	char A[Max];
	int stack[Max];
	int buff;

	while (scanf("%s", A) != EOF) {
		if (A[0] == '+') {
			a = pop(stack);
			b = pop(stack);
			push(stack, a + b);
		}
		else if (A[0] == '-') {
			a = pop(stack);
			b = pop(stack);
			push(stack, b - a);
		}
		else if (A[0] == '*') {
			a = pop(stack);
			b = pop(stack);
			push(stack, a * b);
		}
		else {
			push(stack, atoi(A));
		}
	}

	printf("%d\n", pop(stack));

	return 0;
}