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

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

int s[100],top;

int main()
{
  int n,m,f;
  top = 0;
  char t[100];
  while(1){
    f = scanf("%s",t);
    if(f==EOF) break;
    if(t[0]=='+'){
      n = pop();
      m = pop();
      push(n+m);
    }
    else if(t[0]=='-'){
      n = pop();
      m = pop();
      push(m-n);
    }
    else if(t[0]=='*'){
      n = pop();
      m = pop();
      push(n*m);
    }
    else{
      push(atoi(t));
    }
  }

  printf("%d\n",pop());

  return 0;
}

void push(int n)
{
  s[++top] = n;
}

int pop(void)
{
  top--;
  return s[top+1];
}


  
      
    
      

  

