#define MAX 101

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

void initialize();

void push(int x);

int pop();

bool isEmpty();

bool isFull();

int top = 0;
int S[MAX] = {};

int main(void) {
	int a, b;
	char s[2];

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

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

	return 0;
}

void initialize() {
	top = 0;
}

bool isEmpty() {
	if (top == 0)
		return 1;
	else
		return 0;
}

bool isFull() {
	if (top >= MAX - 1)
		return 1;
	else
		return 0;
}

void push(int x) {
	if (!isFull())
		S[++top] = x;
}

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