#include <stdio.h>
#include <assert.h>

#define BUF_SIZE 1000
#define STACK_SIZE 1000

static int stack[STACK_SIZE];
static int top;

void initialize(void)
{
  top = 0;

  return ;
}

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

  return;
}

int pop(void)
{
  top--;
  assert(top >= 0);

  return stack[top];
}

void print_stack(void)
{
  int i;

  for(i = 0; i < top; i++){
    printf("%d\n", stack[i]);
  }
  return;
}

int main(void)
{
  char buf[BUF_SIZE];
  char c;
  int n0, n1;

  while((c = fgetc(stdin)) != '\n'){
    if(c == ' ' ) continue;

    if(isdigit(c)){
      int i = 0;
      do{
        buf[i] = c;
        i++;
        c = fgetc(stdin);
      }while(isdigit(c));

      ungetc(c, stdin);

      buf[i] = '\0';
      push(atoi(buf));
      continue;
    }

    /* print_stack(); */

    switch(c){
    case '+':
      n1 = pop();
      n0 = pop();
      push(n0 + n1);
      break;
    case '-':
      n1 = pop();
      n0 = pop();
      push(n0 - n1);
      break;
    case '*':
      n1 = pop();
      n0 = pop();
      push(n0 * n1);
      break;
    default:
      assert(0);
    }
  }

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

  return 0;
}