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

void push(int);
int pop();

int head,Str[100000];

int main() {

  char str[100000];
  int a,b;
  head=0;

  while(scanf("%s",str) != EOF) {
    
    if(str[0] == '+') {
      a = pop();
      b = pop();
      push(a+b);
      continue;
    }

    if(str[0] == '-') {
      b = pop();
      a = pop();
      push(a-b);
      continue;
    }
    
    if(str[0] == '*') {
      a = pop();
      b = pop();
      push(a*b);
      continue;
    }
    
    push(atoi(str));
    
  }
  
  printf("%d\n",pop());
  
  return 0;

}

void push(int a) {

  head++;
  Str[head] = a;

}

int pop(void) {
  
  head--;
  return Str[head+1];

}
