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

int pop();
void push( int data );

int top;
int place[100];


int main(){
  top = 0;
  int nai,yo;
  int x;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      
      push(pop() + pop());
      

    } else if ( s[0] == '-' ){
      
      nai = pop();
      yo  = pop();

      push(yo - nai);

    } else if ( s[0] == '*' ){

      push(pop() * pop());
      

    } else {
      x = atoi(s);
      push(x);

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

  return 0;
}

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

void push(int data)
{
  top++;
  place[top] = data;
}




  

