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

#define N 1000

int array[N];
int top;

void push(int);
int pop(void);

int main(){

  char in[N];
  int i=0;
  int a,b;
  int flag;

  while(1){

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

  return 0;
}

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

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

