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

#define MAX 100

void initialize(void);
int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

int S[MAX];
int top = 0;


int main(int argc, char const *argv[]) {

  int num1,num2;
  char c[MAX];

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

    if( c[0] == '+' ){
      num1 = pop();
      num2 = pop();
      push(num2+num1);
    }else if( c[0] ==  '-' ){
      num1 = pop();
      num2 = pop();
      push(num2-num1);
    }else if( c[0] == '*' ){
      num1 = pop();
      num2 = pop();
      push(num2*num1);
    }else{
      push(atoi(c));
    }

  }

  printf("%d\n",S[1]);

  return 0;
}

void initialize(void){
  top = 0;
}

int isEmpty(void){
  if( top == 0 )
    return 1;
  return 0;
}

int isFull(void){
  if( top >= MAX-1)
    return 1;
  return 0;
}

void push(int x){
  if( isFull() ){
    fprintf(stderr,"?????????????????????\n");
    exit(1);
  }

  top++;
  S[top] = x;
}

int pop(void){
  if( isEmpty() ){
    fprintf(stderr,"??¢??????????????????\n");
    exit(2);
  }

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