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

int top = -1, S[105];

void push(int x){
  top++;
  S[top] = x;
}

int pop(){
  top--;
  return S[top+1];
 }

int main(void)
{
  char data[10];
  int S[105], a, b, n;

  while(scanf("%s", data) != EOF){
    if(data[0] == '+'){
      a = pop();
      b = pop();
      push(b+a);
    }
    else if(data[0] == '-'){
      a = pop();
      b = pop();
      push(b-a);
    }
    else if(data[0] == '*'){
      a = pop();
      b = pop();
      push(b*a);
    }
    else{
      n = atoi(data);
      push(n);
    }
  }
  printf("%d\n", pop());

    return 0;
}