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

void push(int);
int pop(void);

int n[100],top=0;

int main(){
  int x,ans1=0,ans2=0;
  char s[100];

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

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

  return 0;
}

void push (int x){

  top++;
  n[top]=x;
  
}

int pop(void){

  top--;
  return n[top+1];

}

