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


void push(int);
int pop(void);
int isEmpty(void);
int isFull(void);
void initialize(void);
int top;
int S[100];

int main()
{
	int c,b;
	
	char x,a;
	
initialize();
	while(scanf("%c",&x) != EOF) {
		switch (x) {
		case ' ':
			break;
		case '+':
			b=pop();
			c=pop();
			push(c+b);
			break;
		case '*':
			b=pop();
			c=pop();
			push(c* b);
			break;
		case '-':
			b=pop();
			c=pop();
			push(c-b);
			break;
			case '\n':
				printf("%d\n",pop());
				exit(0);
		default:
			push(atoi(&x));
			break;
		}
	}
	return 0;
}

void initialize() {
  top = 0;
}

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

int isFull() {
   return top >= 100 - 1;
   }

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

int pop() {
	   if( isEmpty()) exit(0);
top--;
     return S[top+1];
     
     }
