#include <bits/stdc++.h>
using namespace std;
void solve() {
  string str;
  cin >> str;
  long long last = -1;
  long long ans = 0;
  for (long long i = 0; i + 3 < str.size(); i++) {
    if (str.substr(i, 4) == "bear") {
      long long right_chars = str.size() - (i + 3);
      long long between = i - last;
      last = i;
      ans += between * right_chars;
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
