#include <bits/stdc++.h>
using namespace std;
int main(void) {
  char s[5000];
  char s1[5] = "bear";
  int b[5000] = {0};
  int i, j, k, len, t, n = 0;
  long long int sum = 0;
  scanf("%s", s);
  len = strlen(s);
  for (i = 0; i < len - 3; i++) {
    if (s[i] == 'b') {
      bool t = true;
      for (j = 1; j < 4; j++)
        if (s[i + j] != s1[j]) t = false;
      if (t) {
        b[n] = i;
        n++;
      }
    }
  }
  sum = (b[0] + 1) * (len - b[0] - 3);
  for (i = 1; i < n; i++) {
    sum += (b[i] - b[i - 1]) * (len - b[i] - 3);
  }
  if (n == 0) sum = 0;
  printf("%I64d\n", sum);
  return 0;
}
