#include <bits/stdc++.h>
using namespace std;
int conversion(string p) {
  int o;
  o = atoi(p.c_str());
  return o;
}
string toString(int h) {
  stringstream ss;
  ss << h;
  return ss.str();
}
int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); }
int lcm(int a, int b) { return (a * (b / gcd(a, b))); }
int main() {
  ios::sync_with_stdio(1);
  string a;
  cin >> a;
  int c = 0, res = 0;
  vector<pair<int, int> > M;
  while (a.find("bear") >= 0 && a.find("bear") <= a.size()) {
    M.push_back(make_pair(a.find("bear"), a.find("bear") + 4));
    a.replace(a.find("bear"), 4, "hola");
  }
  for (int i = 0; i < M.size(); i++) {
    while (c <= M[i].first) {
      for (int j = a.size(); j >= M[i].second; j--) {
        res++;
      }
      c++;
    }
  }
  cout << res << endl;
}
