#include <bits/stdc++.h>
char s[100] = "bear", str[10000];
int check(int index) {
  int i;
  for (i = index; i <= index + 3; i++) {
    if (str[i] != s[i - index]) return 0;
  }
  return 1;
}
int main() {
  int len, i, j;
  while (scanf("%s", str) != EOF) {
    int ans = 0, index = 0;
    int len = strlen(str);
    for (i = 0; i <= len - 4; i++) {
      if (check(i)) ans += (i + 1 - index) * (len - (i + 3)), index = i + 1;
    }
    printf("%d\n", ans);
  }
  return 0;
}
