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

int A[1000];
int i;
void push(int s);
int pop();
int main()
{
  int x,y;
  char su[100];
  i=0;  
  while(scanf("%s",su)!= EOF){   
    if(su[0]=='+'){
      x = pop();
      y = pop();
      push(x+y);
    }
    else if(su[0]=='-'){
      x = pop();
      y = pop();
      push(y-x);
    }
    else if(su[0]=='*'){
      x = pop();
      y = pop();
      push(x*y);  
    }
    else{
      push(atoi(su));
    }   
  } 
  printf("%d\n",pop());
  return 0;                          
}               

void push(int s){
 
  A[++i]=s;
}
int pop(){
  i--;
  return A[i+1];
}

