#include <stdio.h>
#include <stdlib.h>
#define N1 100
#define N2 99

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

int top,S[N1];

int main(){
  int n, n1, n2, i;
  char c;

  while(1){
    scanf("%c", &c);
    if(c == '\n') break;
    n = atoi(&c);
    if(n != 0) push(n);
    else if(c == '+' || c == '-' || c == '*'){
      n2 = pop();
      n1 = pop();
      if(c == '+') push(n1 + n2);
      if(c == '-') push(n1 - n2);
      if(c == '*') push(n1 * n2);
    }
  }

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

  return 0;
}

void push(int x){
  if(isFull() == -1){
    printf("Stack overflow\n");
    exit(1);
  }
  else{
    S[top] = x;
    top++;
  }
}

int pop(){
  if(isEmpty() == -1){
    printf("Stack underflow\n");
    exit(1);
  }
  else{
    top--;
    return S[top];
  }
}

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

int isFull(){
  if(top == N1) return -1;
  else return 0;
}