#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 100

int top,arr[N];

void push(int);
int pop ();

int main (){
  int x,y;
  top=0;
  char input[N];
  
  while(scanf("%s",input)!= EOF){
  if(input[0]=='+'){
    x=pop();
    y=pop();
    push(x+y);
  }
  else if (input[0] =='-'){
    x=pop();
    y=pop();
    push(y-x);
  }
  else if (input[0]=='*'){
    x=pop();
    y=pop();
    push(x*y);
  }
  else {
    push(atoi(input));
  }
  }

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

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

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

