#include <stdio.h>
#include<stdlib.h>
#define N 100
int main(){
  int a[N], i = 0, x, y;
  char hoge[N];
  while( scanf("%s",hoge) != EOF ){
    if(*hoge == '+'){
        x = a[--i];
        y = a[--i];
        a[i++] = y + x;
    }else if(*hoge == '-'){
        x = a[--i];
        y = a[--i];
        a[i++] = y - x;
    }else if(*hoge == '*'){
        x = a[--i];
        y = a[--i];
        a[i++] = y * x;
    }else if(*hoge == '/'){
        x = a[--i];
        y = a[--i];
        a[i++] = y / x;
    }else{
        a[i++] = atoi(hoge);
    }
    
  }
  printf("%d\n", a[--i]);
  return 0;
}


