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

int sp;
int stack[N];

void push(int x){
  if(sp == N-1) exit(1); // isFull
  sp = sp+1;
  stack[sp] = x;
}

int pop(void){
  if(sp == 0) exit(1); // isEmpty
  sp = sp-1;
  return stack[sp+1];
}

int main(){
  int a,b,x,i,ans;
  char form[N];

  // input
  while(scanf("%s",form) != EOF){

    // operate
    switch(form[0]){
    case '+':
      b = pop();
      a = pop();
      push(a+b);
      break;
    case '-':
      b = pop();
      a = pop();
      push(a-b);
      break;
    case '*':
      b = pop();
      a = pop();
      push(a*b);
      break;
    default:
      x = atoi(form);
      push(x);
      break;
    }

  }

  // output
  ans = pop();
  printf("%d\n",ans);

  return 0;
}