#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define MAXOP 100
#define MAXVAL 100
void push(int);
int pop(void);
int main()
{
  char t;
  int op2;
  char s[MAXOP];

	while(1) {
	  scanf("%c",&t);
		switch (t) {
		case '+':
			push(pop() + pop());
			break;
		case '*':
			push(pop() * pop());
			break;
		case '-':
			op2 = pop();
			push(pop() - op2);
			break;
		case '\n':
			printf("%d\n", pop());
			exit(0);
			break;
		case ' ':
		  break;
		default:
		  push(atoi(&t));
		  break;
		}
	}
	return 0;
}


int s = 0;
double val[MAXVAL];

void push(int f)
{
	if (s < MAXVAL)
		val[s++] = f;
}

int pop(void)
{
	if (s > 0)
		return val[--s];
	else {
		return 0;
	}
}



