#include <bits/stdc++.h>
using namespace std;
int main() {
  string str, str2;
  getline(cin, str);
  int ct = 0, y = 0, x, siz;
  str2 = "aaaa";
  siz = str.size();
  for (int i = 0; i <= siz - 4; ++i) {
    x = str.find("bear");
    if (x >= 0) {
      str.replace(x, 4, str2);
      ct = ct + ((siz - (x + 3)) * (x + 1 - y));
      y = x + 1;
    }
  }
  cout << ct << endl;
  return 0;
}
