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