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

#define MAX 200

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

int g_top = 0;
int g_s[100];

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

  while(scanf("%s",s) != EOF){
    switch(s[0]){
    case '+':
      a = pop();
      b = pop();
      push(b+a);
      break;
    case '-':
      a = pop();
      b = pop();
      push(b-a);
      break;
    case '*':
      a = pop();
      b = pop();
      push(b*a);
      break;
    default:
      x = atoi(s);
      push(x);
      break;
    }
  }

  printf("%d\n",g_s[g_top]);
  
  return 0;
}

int isEmpty(){
  if (g_top == 0) return 1;
  else return 0;
}

int isFull(){
  if(g_top >= MAX - 1) return 1;
  else return 0;
}

void push(int x){
  if(isFull() == 1) fprintf(stderr,"error,push\n");
  g_top++;
  g_s[g_top] = x;
}

int pop(){
  if(isEmpty() == 1)  fprintf(stderr,"error,pop\n");
  g_top--;
  return g_s[g_top+1];
}

