#include <bits/stdc++.h>
char str[5004];
int main() {
  scanf("%s", str);
  int n = strlen(str);
  int pb = -1;
  int answer = 0;
  for (int _k = (0), _n = (n - 4), i = _k; i <= _n; ++i) {
    if (strncmp(str + i, "bear", 4) == 0) {
      if (pb == -1)
        answer = (i + 1) * (n - i - 3);
      else
        answer += (i - pb) * (n - i - 3);
      pb = i;
    }
  }
  printf("%d", answer);
  return 0;
}
