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

#define XMAX 1000
#define SMAX 199

void initialize (void);
int push (int);
int pop (void);
int isEmpty(void);
int isFull (void);
int top,s[SMAX];

int main (void)
{
  char x[500];
  int i,a,b,c;

  //????????\????????°??????????????§????????????

  for (i = 0 ; i < XMAX ; i++){
    scanf ("%c",&x[i]);
    if (x[i] == '\n')
      break;
  }

  initialize();

  for (i = 0 ; i < XMAX-1 ; i++){

    if (x[i] == '+'){
      a = pop();
      b = pop();
      c = a + b;
      push(c);
    }

    else if (x[i] == '-'){
      a = pop();
      b = pop();
      c = a - b;
      push(c);
    }

    else if (x[i] == '*'){
      a = pop();
      b = pop();
      c = a * b;
      push(c);
    }

    else if (x[i] == ' ' || x[i] == '\n'){
      continue;
    }

    else
      push((int)x[i]);

  }

  printf ("%d\n",s[1]);

  return 0;
}

void initialize (void){
  top = 0;
}

int push (int x)
{
  if (isFull())
    exit(2);

  top++;
  s[top] = x;
  return 0;
}

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

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

int isFull (void)
{
  return top >= SMAX -1;
}