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

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

  while(scanf("%c", &c[i]) != EOF){

    if(c[i] == '+') {
      a[i-2] = a[i-2] + a[i-1];
      i=i-2;
    }
    else if(c[i] == '-'){
      a[i-2] = a[i-2] - a[i-1];
      i=i-2;
    }
    else if(c[i] == '*'){
	a[i-2] = a[i-2] * a[i-1];
	i=i-2;
    }
    else if(c[i] >= '0' && c[i] <= '9'){
      a[i] = c[i] - 48;
      }

    else if(c[i] == ' '){
      i = i-2;
      continue;
    }
    i++;
  }
  
  printf("%d\n",a[0]);
  
  return 0;
}