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