#include <bits/stdc++.h>
using namespace std;
pair<int, int> dirs[] = {{1, 0},   {-1, 0}, {0, 1},  {0, -1},
                         {-1, -1}, {-1, 1}, {1, -1}, {1, 1}};
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  string inp;
  cin >> inp;
  string sub = "bear";
  vector<unsigned int> positions;
  auto pos = inp.find(sub, 0);
  unsigned int ans = 0;
  while (pos != string::npos) {
    positions.push_back(pos);
    pos = inp.find(sub, pos + 1);
  }
  int prev = -1;
  for (unsigned int i = 0; i < positions.size(); ++i) {
    ans += (inp.length() - (positions[i] + sub.length() - 1)) *
           (positions[i] - prev);
    prev = positions[i];
  }
  cout << ans << endl;
  return 0;
}
