#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 100
#define F 0

int s[MAX],top = 0;

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

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

void push(int n){
  if(isFull == F) {
    fprintf(stderr, "OverFlow");
    exit(1);
  }
  top++;
  s[top] = n;
}

int pop() {
  if (isEmpty() == F) {
    fprintf(stderr, "UnderFlow");
    exit(1);
  }
  top--;
  return s[top+1];
}

int main () {
  int x, y;
  char c[MAX];

  while(scanf("%s", c) != EOF) {
    if(s[0] == '+') {
      x = pop();
      y = pop();
      push(x + y);
    }
    else if(s[0] == '-') {
      x = pop();
      y = pop();
      push(x - y);
    }
    else if(s[0] == '*') {
      x = pop();
      y = pop();
      push(x * y);
    }  
    else {
      x = atoi(c);
      push(x);
    }
      
  }

  printf("%d\n", s[0]);

  return 0;
}