#include <bits/stdc++.h>
int n;
char str[5008];
int mem[5001][5001];
int sol = 0;
int calc(int lf, int rg) {
  if (mem[lf][rg]) return mem[lf][rg];
  mem[lf][rg] = -1;
  if (rg - lf < 3) return -1;
  if (rg - lf == 3) {
    if (str[lf] == 'b' && str[lf + 1] == 'e' && str[lf + 2] == 'a' &&
        str[rg] == 'r')
      mem[lf][rg] = 1;
  } else {
    if (calc(lf + 1, rg) > 0 || calc(lf, rg - 1) > 0) mem[lf][rg] = 1;
  }
  if (mem[lf][rg] > 0) sol++;
  return mem[lf][rg];
}
int main() {
  scanf("%s", str);
  n = 0;
  while (str[n] != '\0') n++;
  if (n > 3) {
    for (int i = 0; i < n; i++) {
      for (int j = i; j < n; j++) {
        calc(i, j);
      }
    }
  }
  printf("%d\n", sol);
  return 0;
}
