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

void push(int);
void pop(char);


int count = 0;
int stac[100];

int main(void){
  int i,a;
  char mark;
  
  while(1){
    scanf("%c",&mark);
      if(mark  =='\n') break;
    if(mark=='+' ||mark=='-' ||mark=='*' ){
      pop(mark); 
    }
    else if(mark>='0' && mark <='9'){
      a=atoi(&mark);
      push(a);
    }
    else continue;
  }
  printf("%d\n",stac[0]);
  return 0;
}

void push(int a){
  if(count==100) exit(1);
  stac[count]=a;
  count++;

}

void pop(char a){
  if(count==0) exit(2);
  if(a=='+'){
    stac[count-2]+=stac[count-1];
  }
  else if(a=='-'){
    stac[count-2]-=stac[count-1];
  }
  else if(a=='*'){
    stac[count-2]*=stac[count-1];
  }
  count--;
}