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

int main(){
  int x,y;
  char s[100];
  int stack[100];
  int n=0;

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      x = stack[--n];
      y = stack[--n];
      stack[n++] = x+y;
    } else if ( s[0] == '-' ){
      x = stack[--n];
      y = stack[--n];
      stack[n++] = y - x;
    } else if ( s[0] == '*' ){
      x = stack[--n];
      y = stack[--n];
      stack[n++]=x*y;
    } else {
      x = atoi(s);
      stack[n] = x;
      n++;

    }
  }
  printf("%d\n",stack[n]);

  return 0;
}