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

int main(){
  int x, key=0;
  int number[100];
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
		number[key-3] = number[key-2] + number[key-3];

    } else if ( s[0] == '-' ){
		number[key-3] = number[key-2] - number[key-3];

    } else if ( s[0] == '*' ){
		number[key-3] = number[key-2] * number[key-3];

    } else {
      x = atoi(s);
      number[key] = x;
      key++;
    }
  }
  printf("%s\n",number[0]);

  return 0;
}