#include <bits/stdc++.h>
int main(void) {
  char wrd[5002];
  int i, l, cnt = 0, j;
  gets(wrd);
  l = strlen(wrd);
  for (j = 0; j < l; j++) {
    for (i = j + 3; i < l; i++) {
      if (wrd[i - 3] == 'b' && wrd[i - 2] == 'e' && wrd[i - 1] == 'a' &&
          wrd[i] == 'r') {
        cnt += (l - i);
        break;
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}
