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

int top;
int S[1000];

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

int main(){
  char inp[1000];
  int  top = 0;
  int f,s;

  while(scanf("%s", inp) != EOF){
    if(inp[0] == '\n') break;
    if(inp[0] == '+'){
      f = pop();
      s = pop();
      push(f + s);
    }
    else if(inp[0] == '-'){
      s = pop();
      f = pop();
      push(f - s);
    }
    else if(inp[0] == '*'){
      f = pop();
      s = pop();
      push(f * s);
    }
    else {
      push(atoi(inp));
    }
  }

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

  return 0;
}

void push(int x){
  S[top] = x;
  top++;
}

int pop(){
  top--;
  return S[top];
}

