#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  string str;
  int res = 0, f, len, min = 0;
  cin >> str;
  len = str.length();
  size_t found = str.find("bear");
  if (found == string::npos) goto End;
  do {
    f = ((int)found) + 1;
    res += (f - min) * (len - f - 2);
    min = f;
    found = str.find("bear", found + 4);
  } while (found != string::npos);
End:
  cout << res << "\n";
}
