#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  size_t f = s.find("bear");
  int ans = 0;
  while (f != string::npos) {
    ans += (f + 1) * (s.length() - f - 3);
    s.erase(0, f + 1);
    f = s.find("bear");
  }
  cout << ans << endl;
  return 0;
}
