#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100
#define M 1000

void push(int *, int);
int pop(int *);

int top=0;

int main(){
  int a, b, S[M];
  char s[N];

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

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

  return 0;
}

void push(int *S, int a){
  S[++top] = a;
}

int pop(int *S){
  top--;
  return S[top+1];
}

