#include <stdio.h>
#define MAX 100
 
void push(int);
int pop();
 
int top = 0, S[MAX];
 
int main()
{
  int  x, y, z;
  char a[MAX];
 
  while(scanf("%s",a) != EOF){
    if(a[0] == '+'){
      x = pop();
      y = pop();
      push(y+x);
    }
    else if(a[0] == '-'){
      x = pop();
      y = pop();
      push(y-x);
    }
    else if(a[0] == '*'){
      x = pop();
      y = pop();
      push(y*x);
    }
    else{   
      push(atoi(a));
    }
  }
   
  printf("%d\n",pop());
 
  return 0;
}
 
void push(int x)
{
  top++;
  S[top] = x;
}
 
int pop()
{
  top--;
  return S[top+1];
}