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

int main()
{
    int ans[200];
    int i=-1;//top.array
///bunnki ???????????\????????????????????????????????????????????????
  char s[100];
  while(scanf("%s",s)!= EOF)
  {

    if(s[0]=='+')
      {
        ans[i-1]=ans[i]+ans[i-1];
        i--;
      }
    else if(s[0]=='-')
    {
      ans[i-1]=ans[i-1]-ans[i];
      i--;
    }
    else if(s[0]=='*')
    {
      ans[i-1]=ans[i-1]*ans[i];
      i--;
    }
    else //read number, extend array
    {
      i++;
      ans[i]= atoi(s);
    }
  }
  printf("%d\n",ans[i]);
  return 0;
}