#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[5000], a[5000];
  char b[] = "bear";
  int count = 0, j = 0;
  scanf("%s", &s);
  int i = 0;
  int n = strlen(s);
  printf("%s", a);
  for (i = 0; i < n; i++) {
    for (j = i; j < n; j++) {
      if (s[j] == 'b' && s[j + 1] == 'e' && s[j + 2] == 'a' &&
          s[j + 3] == 'r') {
        count = count + n - j - 3;
        count = count + j - i;
        count = count + (n - j - 4) * (j - i);
        i = j + 1;
      }
    }
  }
  printf("%d", count);
  return 0;
}
