#include <stdio.h>

#define MAX 101

int main(){

  char s[1000];
  char t;
  int num = 0, stack[MAX];
  int top = 0;
  int a,b;
  while(1){
    scanf("%c", &t);
    if(t >= '0' && t <= '9'){
      num = 0;
      while(1){
	num *= 10;
	num += t-'0';
	scanf("%c", &t);
	if(t < '0' || t > '9'){
	  stack[top] = num;
	  top++;
	  break;
	}
      }
    }
    else if(t == ' '){
    }
    else if(t == '\n'){
      break;
    }
    else{
      a = stack[top-2], b = stack[top-1];
      if(t == '+'){
	stack[top-2] = a + b;
      }
      else if(t == '-'){
	stack[top-2] = a - b;
      }
      else if(t == '*'){
	stack[top-2] = a * b;
      }
      else if(t == '/'){
	stack[top-2] = a / b;
      }
      top--;
    }

  }

  printf("%d\n", stack[0]);
  return 0;
}