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

#define MAX 1000

int calc(char,int,int);

int main() {
  char c;
  int array[MAX] , pos = 0 , a , b , res;

  memset(array,-1,sizeof(array));

  while ((c = getchar()) != '\n') {
    if(c == ' '){
      continue;
    }

    if (isdigit(c)) {
      array[pos++] = c - '0';
    } else {
      a = array[pos-2]; array[pos-2] = -1;
      b = array[pos-1]; array[pos-1] = -1;
      pos -= 2;

      res = calc(c,a,b);
      array[pos++] = res;
    }
  }
  printf("%d\n" ,array[0]);

  return 0;
}

int calc (char op , int a , int b){
  int res = -1;

  switch (op) {
  case '+':
    res = a + b;
    break;
  case '-':
    res = a - b;
    break;
  case '*':
    res = a * b;
    break;
  }

  return res;
}