
#include<stdio.h>

int main(void){
  char str[500];
  char c;
  int stack[100];
  int count=0;
  int x,y;
  // fgets(str,500,stdin);
  //printf("%s",str);
  while((c=getchar())!='\n'){
    //printf("%c ",c);
    if(c=='+'){
      //printf("test:+\n");
      y=stack[count-1];
      x=stack[count-2];
      stack[count-2]=x+y;
      count--;
    }else if(c=='*'){
      //printf("test:*\n");
      y=stack[count-1];
      x=stack[count-2];
      stack[count-2]=x*y;
      count--;
    }else if(c=='/'){
      // printf("test:/\n");
      y=stack[count-1];
      x=stack[count-2];
      stack[count-2]=x/y;
      count--;
    }else if(c=='-'){
      // printf("test:-\n");
      y=stack[count-1];
      x=stack[count-2];
      stack[count-2]=x-y;
      count--; 
    }else if(c==' '){
      //printf("test: \n");
      //スルー
    }else{
      //printf("test:123\n");
      stack[count]=(int)(c-'0');
      //printf("%d\n",stack[count]);
      count++;
    } 
    
  }
  printf("%d\n",stack[0]);
  return 0;
}

/*
[16D8104007J@ise75c ~]$ cc kadai03_3a.c -o kadai03_3a
[16D8104007J@ise75c ~]$ ./kadai03_3a
1 2 +
3
[16D8104007J@ise75c ~]$ ./kadai03_3a
1 2 + 3 4 - *
-3
*/

