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

int top;
int A[1000000];

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

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

int main(){
  int x;
  char s[100];
  int y,z;
  top = 0;

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      y = pop();
      z = pop();
      push(y + z);
    } else if ( s[0] == '-' ){
      z = pop();
      y = pop();
      push(y - z);
    } else if ( s[0] == '*' ){
      y = pop();
      z = pop();
      push(y * z);
    } else {
      push(atoi(s));
    }
  }

  printf("%d\n",pop());
  return 0;
}

