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

int pop();
void push(int);
int top,num[1000];

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

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

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