#include<stdio.h>

int i=1;

int atoi(char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

void push(int f[],int x){
  f[++i] = x; 
}

int pop(int f[]){
  return f[i--];
}

int main(){

  char c;
  int f[101],x,y;

  while(scanf("%c",&c)){
    if(c==' ') continue;
    else if(c == '\n') break;
    if('0' <= c && c <= '9'){
      //printf("%c %d\n",c,atoi(c));
      push(f,atoi(c));
      //  printf("%d\n",i);
    }
    else{
      x = pop(f);
      //  printf("%d\n",i);
      y = pop(f);
      //    printf("%d\n",i);
      
      if(c == '+'){
	x += y;
      }
      else if(c == '-'){
	x -= y;
      }
      else if(c == '*'){
	x *= y;
      }
      push(f,x);
      // printf("%d\n",i);
      
    }
  }

  printf("%d\n",f[i]);
  
  return 0;
}


