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

#define MAX 100

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

int top;
int S[MAX];

int main(){
  int x, a, b;
  char s[MAX];

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

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

  return 0;
}

void initialize() {
  top = 0;
}

int isEmpty() {
  return top == 0;
}

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

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

int pop(void) {
  if(isEmpty() == 1) {
    printf("error\n");
    exit(2);
  }
  top--;
  return S[top+1];
}