#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 1000000

void initialized( void );
void push(int);
int  pop(void);
int  isFull(void);
int  isEmpty(void);

int S[100];
int top;

void initialized( void )
{
  top = 0;
}

void push(int x)
{
  if(isFull() == 0){
  top++;
  S[top] = x;
  }
  else fprintf(stderr, "error\n");
}

int  pop(void)
{
  if(isEmpty() == 0){
  top--;
  return S[top+1];
  }
  else fprintf(stderr, "error\n");
}

int isFull( void )
{
  if(top > N -1) return 1;
  else return 0;
}

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

int main()
{
  int a, b, n;
  char C[N];
  while( scanf("%s", C) != EOF ){
    if( C[0] == '+' ){
      a = pop();
      b = pop();
      push( a + b );
    }
    else if( C[0] == '-' ){
      a = pop(); 
      b = pop();
      push( b - a );
    }
    else if( C[0] == '*' ){
      a = pop();
      b = pop();
      push( a * b );
    }
    else push( atoi(C) );
  }    

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

  return 0;
}