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

int sp = 0;
int stack[1000];

void show(){
	int i;
	for(i = 0; i < sp; i++){
		printf("%d ",stack[i]);
	}
	printf("\n");
}

int main(void){
	int i = 0;
	char input[100000];
	fgets(input, sizeof(input), stdin);
	while(input[i] != '\n'){
	switch(input[i]){
		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
		stack[sp] = (input[i++] - '0');
		while(input[i] >= '0' && input[i] <= '9'){
			stack[sp] = stack[sp]*10 + (input[i++] - '0');
		} 
		sp++;
		break;

		case '+':
			sp -= 2;
			stack[sp] = stack[sp] + stack[++sp];
			i++;
			break;

		case '-':
			sp -= 2;
			stack[sp] = stack[sp] - stack[++sp];
			i++;
			break;

		case '*':
			sp -= 2;
			stack[sp] = stack[sp] * stack[++sp];
			i++;
			break;
		default:
			i++;
			break;
		}
	}
	//show();
	//printf("%d\n",sp);
	printf("%d\n",stack[0]);
}