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

#define MAX 100

int top=0,S[MAX];

int isEmpty();
int isFull();
void push(int);
int pop();

int main(){
  int a,b;
  char s[MAX];

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

  return 0;
}

/*int isEmpty(){
  if(top == 0) return 1;
  return 0;
}

int isFull(){
  if(top >= MAX - 1) return 1;
  return 0;
}
*/
void push(int x){
  /*  if(isFull()==1) printf("overflow\n");*/
  top++;
  S[top] = x;
}

int pop(){
  /*if(isEmpty()==1) printf("underflow\n");*/
  top--;
  return S[top+1];
}