/* ALDS1_3_A_Stack */

#define _CRT_SECURE_NO_WARNINGS

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

#define N 200

char top;
int stack[N];

void push(int m);
int pop();

int main(void){
	char A[N];
	int x, y;
	top = 0;
	while((scanf("%s", A)) != EOF){
		if(((A[0] - '0') >= 0) && ((A[0] - '0') <= 9)) push(atoi(A));
		else{
			y = pop(); 
			x = pop(); 
			switch(A[0]){
				case '+': push(x + y); break;
				case  '-': push(x - y); break;
				case '*':  push(x * y); break;
				case '/':  push(x / y); break;
				default : break;
			}
		}
	}

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

	return 0;
}

void push(int m){
	stack[top++] = m;
}

int pop(){
	int ret = stack[--top];

	return ret;
}
