#include <bits/stdc++.h>
using namespace std;
int main() {
  char c[5005];
  gets(c);
  int len = static_cast<int>(strlen(c));
  int lastbear = 0;
  int p = 0, q = 0;
  int sum = 0;
  bool isforfirst = true;
  for (int i = (0); i < (len); i++) {
    if (c[i] == 'b' && c[i + 1] == 'e' && c[i + 2] == 'a' && c[i + 3] == 'r') {
      p = i - lastbear;
      if (isforfirst) {
        isforfirst = false;
        p++;
      }
      q = len - i - 3;
      sum += (p * q);
      lastbear = i;
      i = i + 3;
    }
  }
  cout << sum;
  return 0;
}
