#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top = 0;
int S[1000];

void push(char n){
  if(top >= 1000) fprintf(stderr,"stac overflow\n"); exit(1);
  S[++top] = n;
}

int pop(){
  if(top == 0) fprintf(stderr,"stac underflow\n"); exit(1);
  top--;
  return S[top+1];
}

int main(){
  int a;
  int b;
  int c;
  int x;

  while((c = getchar()) != EOF){
    if(isdigit(c)){
      ungetc(c,stdin);
      scanf("%d",&x);
      push(x);
    }
    else if(c == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if(c == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }
    else if(c == '*'){
      b = pop();
      a = pop();
      push(a * b);
    }
    else if(c == '/'){
      b = pop();
      a = pop();
      push(a / b);
    }
  }
  printf("%d\n",pop());
  return 0;
}



