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

int top,s[100];

int pop();
void push(int);

int main(){
  int x,y,a;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      x = pop();
      y = pop();
      push(x + y);
    }
    else if ( s[0] == '-' ){
      x = pop();
      y = pop();
      push(y - x);
    }
    else if ( s[0] == '*' ){
      x = pop();
      y = pop();
      push(x * y);
    }
    else {
      a = atoi(s);
      push(a);
    }
  }
  printf("%d\n",pop());
  return 0;
}


int pop(){
  top--;
  return s[top+1];
}

void push(int x){
  top++;
  s[top] = x;
}


