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

void push(int);
int pop();

int top;
int d[1000];

int main()
{
  
  char a[100];
  int b, c;

  top = 0;
  
  while(scanf("%s",a)!=EOF){
    if(a[0]=='-'){
      b = pop();
      c = pop();
      push(c-b);
    }
    else if(a[0]=='+'){
      b = pop();
      c = pop();
      push(b+c);
    }
    else if(a[0]=='*'){
      b = pop();
      c = pop();
      push(b*c);
    }
    else push(atoi(a));
  }

  printf("%d\n",pop());

  return 0;

}

void push(int a)
{
  d[++top] = a;
}

int pop()
{
  top--;
  return d[top+1];
}


