#include <bits/stdc++.h>
using namespace std;
int main() {
  const string toFind = "bear";
  string s;
  cin >> s;
  vector<int> w;
  {
    int i = 0;
    while (s.find(toFind, i) != string::npos) {
      i = s.find(toFind, i);
      w.push_back(i);
      i++;
    }
  }
  int N = (int)s.size();
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i; j < N; j++) {
      vector<int>::iterator it = lower_bound(w.begin(), w.end(), i);
      if (it != w.end()) {
        if (*it + (int)toFind.size() - 1 <= j) {
          ans++;
        }
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
