#include <stdio.h>
#include <stdlib.h>
#define Max 100
#define n 99
int push(int *, int);
int pop(int *);
int isEmpty(int);
int isFull(int);
int calc(int *, int);
static int top=0;

int main(){
  int S[Max];
  int i,a,len;
  char x[Max];
  char c;

  while(1){
    if(scanf("%s",x)==EOF) break;
    if(x[0]>='0' && x[0]<='9'){
      a = atoi(x);
      push(S,a);
    }
    else if(x[0]=='+' || x[0]=='-' || x[0]=='*'){
      c = x[0];
      calc(S,c);
    }   
  }
  
  printf("%d\n",S[top]);
  
  return 0;
}


int push(int *S,int x)
{
  if(isFull(top)==0) exit(8);
  top++;
  S[top] = x;
  return S[top];
}

int calc(int *S,int x){
  int Ans=0;
  if(x=='+')       Ans = S[top-1] + S[top];
  else if(x=='-')  Ans = S[top-1] - S[top];
  else if(x=='*')  Ans = S[top-1] * S[top];
  pop(S);
  S[top] = Ans;
  return S[top];
}

int pop(int *S)
{
  if(isEmpty(top)==0) exit(8);
  top--;
  return S[top+1];
}

int isFull(int top)
{
  if(top>=Max-1) return 0;
  else return 1;
}

int isEmpty(int top)
{
  if(top<=0) return 0;
  else return 1;
}