#include <bits/stdc++.h>
char str[5005];
int pos[5005];
int main() {
  while (~scanf("%s", str)) {
    int p = 1;
    memset(pos, 0, sizeof(int));
    int len = (int)strlen(str);
    for (int i = 0; i < len; i++) {
      if (str[i] == 'b' && str[i + 1] == 'e' && str[i + 2] == 'a' &&
          str[i + 3] == 'r')
        pos[p++] = i;
    }
    int ans = 0;
    int num;
    pos[0] = -1;
    for (int i = 1; i < p; i++) {
      num = (len - pos[i] - 3) * (pos[i] - pos[i - 1]);
      ans += num;
    }
    printf("%d\n", ans);
  }
  return 0;
}
