#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 initialize(int);
int calc(int *, int);
static int top;

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

  initialize(top);

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

int initialize(int top)
{
  top = 0;
  return top;
}

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;
}