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

int S[100];
int top = 0;

void push(int x);

int pop(void);

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

  while( scanf("%s",s) != EOF ){

    if ( s[0] == '+' ){

      push(pop() + pop());


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

      sub = pop();
      push(pop() - sub);

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

      push(pop() * pop());

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

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

  return 0;
}

void push(int x){

  top++;
  S[top] = x;

}

int pop(void){

  top--;
  return S[top+1];
}