#include <bits/stdc++.h>
int main() {
  char c[5100];
  int i, j, k = 0, l, count = 0;
  scanf("%s", c);
  l = strlen(c);
  j = -1;
  for (i = 0; i < l; i++) {
    if (strncmp(c + i, "bear", 4) == 0) {
      count = count + (i - j) * (l - i - 3);
      j = i;
    }
  }
  printf("%d\n", count);
  return 0;
}
