#include <stdio.h>
#include <ctype.h>

int sp = 0;
int val[100];

void push(int d){
  val[sp++] = d;
}

int pop(void){
  return val[--sp];
}

int get_number(char *s){
	int  n = 0;
  // char to int
	while (*s >= '0' && *s <= '9') {
		n = n * 10 + (*s - '0');
		s++;
	}
	return n;
}

int calc_rpn(char *s){
	int  n,op2;

	while (*s) {

		if (isdigit((int)*s)) {
			n = get_number(s);
			push(n);
			while (n) {
				n /= 10;
				s++;
			}

		} else {
			switch (*s) {
        case '+':
          push(pop() + pop());
          break;
        case '-':
          op2 = pop();
          push(pop() - op2);
          break;
        case '*':
          push(pop() * pop());
          break;
			}
			s++;
		}
	}
	return pop();
}

int main(){
	char s[1000];
	scanf("%[^\n]*s", s);
	printf("%d\n",  calc_rpn(s));
}

