#include<stdio.h>
#include<stdlib.h>
#define N 200

int main(void){
  int a, b, ans, i=0;
  char *S[N];
  int num[N];

  while(scanf("%s",&S[i]) != EOF){
    i++;
    switch(*S[i]){
    case '+':
      a = atoi(S[i-2]);
      b = atoi(S[i-1]);
      ans = a + b;
      num[i] =ans;
      i=i-2;

    case '*':

      a = atoi(S[i-2]);
      b = atoi(S[i-1]);
      ans = a * b;
      num[i]=ans;
      i=i-2;

    case '-':

      a = atoi(S[i-2]);
      b = atoi(S[i-1]);
      num[i]=ans;
      ans = a - b;
      i=i-2;
    }
  }
  printf("%d\n",num[0]);

}

