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

const int MAX = 100;
int top, S[110];

void causeError() {
	exit(1);
}

void initialize() {
	top = 0;
}

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

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

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

int pop() {
	if (false && isEmpty()) {
		causeError();
	}
	top--;
	return S[top + 1];
}

int main() {
	char s[100];
	int a, b;
	while (scanf("%s", s) != EOF) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			a = pop();
			b = pop();
			push(b - a);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
}

