#include <bits/stdc++.h>
int main() {
  char s[5005];
  int i, j, len, count, m[10010];
  long long ans;
  while (gets(s) != NULL) {
    len = strlen(s);
    for (i = 0, j = 0, count = 0; s[i]; i++) {
      if (s[i] == 'b') {
        if (s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'r') {
          count++;
          m[j] = i;
          m[j + 1] = i + 3;
          j += 2;
          i += 3;
        }
      }
    }
    for (ans = 0, i = 0; i < 2 * count; i += 2) {
      if (i)
        ans += (m[i] - m[i - 2]) * (len - m[i + 1]);
      else
        ans += (m[i] + 1) * (len - m[i + 1]);
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
