#include <bits/stdc++.h>
int main() {
  char s[5010], *p, *q, *f, *p1, *q1, *f1, *u;
  int i, k, t, sum, len, num;
  while (scanf("%s", s) != EOF) {
    sum = 0;
    k = 0;
    len = strlen(s);
    q = &s[len - 1];
    u = f = s;
    while (1) {
      num = 0;
      u = p = strstr(u, "bear");
      if (p == NULL) break;
      if (k == 1) {
        num = num + q - (p + 3) + 1;
        num = num + num * (p - q1 - 1);
        sum += num;
      } else {
        num = num + q - (p + 3) + 1;
        num = num + num * (p - f);
        sum = sum + num;
      }
      q1 = p;
      k = 1;
      u += 4;
    }
    printf("%d\n", sum);
  }
  return 0;
}
