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

int pop();
void push(int);
int s2[100],top=0;

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

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      x = a+b;
      s2[top]=x;
      top++;
    } else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      x = b-a;
      s2[top]=x;
      top++;
    } else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      x = a*b;
      s2[top]=x;
      top++;
    } else {
      x = atoi(s);
      s2[top]=x;
      top++;
    }
  }
  printf("%d\n",x);
  return 0;
}
int pop(){
  top--;
  return s2[top];
}