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

  int data[200] = {1};
  int top=0;

void push(int a) {
  top++;
  data[top] = a;
}

int pop() {
  int a;

  a = data[top];
  top--;
  return a;

}

int main() {
  char  a[100];
  int b, c;
  int i;

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

  printf("%d\n", pop());
  return 0;
}

