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

#define MAX 200

int top,stack[MAX];

void push(int n){
  stack[++top] = n;
}

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

int main(){
  int i,x,y;
  char s[100];

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

  }

  printf("%d\n",pop());
  
  return 0;
}

