// Reverse polish notation                                                                                                           
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  int i, x, y;
  char n[7], op;
  int a[200];

  // input                                                                                                                           
  i = 0;
  while(scanf("%s", n) != EOF) {
    op = n[0];

    if((op == '+') || (op == '-') || (op == '*') || (op == '/')) {
      i--;
      x = a[i - 1];
      y = a[i];
      // pop the two number and calculate
      switch(op) {
      case '+':
        a[i - 1] = x + y;
        break;
      case '-':
        a[i - 1] = x - y;
	break;
      case '*':
        a[i - 1] = x * y;
	break;
      default:
        a[i - 1] = x / y;
	break;
      }
      a[i] = 0;
    }
    
    else {
      // push the number
      a[i] = atoi(n);
      i++;
    }
  }

  printf("%d\n", a[0]);

  return 0;
}

