#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int tameru[100];
int dasiire=0;
void ireru(int);
int nuku(void);

int main(){
  int a,b,c;
  char kazu[100];
  while(scanf("%s",kazu)!=EOF){
    if(strcmp(kazu,"+")==0){
    a=nuku();
    b=nuku();
    ireru(a+b);
    }
    else if(strcmp(kazu,"-")==0){
    a=nuku();
    b=nuku();
    ireru(b-a);
    }
    else if(strcmp(kazu,"*")==0){
    a=nuku();
    b=nuku();
    ireru(a*b);
    }
    else {
      c=atoi(kazu);
      ireru(c);
    }
  }
  printf("%d\n",tameru[0]);
  return 0;
}


void ireru(int a){
  tameru[dasiire]=a;
  dasiire++;
}
int nuku(){
  dasiire--;
  return tameru[dasiire];
}