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