#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<int, int> > v;
  int nb = 0, i = 0, val;
  string s;
  cin >> s;
  while (i < s.size()) {
    if (s[i] == 'b') {
      i++;
      if (s[i] == 'e') {
        i++;
        if (s[i] == 'a') {
          i++;
          if (s[i] == 'r') {
            i++;
            v.push_back(make_pair(i - 4, i));
          }
        }
      }
    } else
      i++;
  }
  val = 0;
  for (i = 0; i < v.size(); i++) {
    nb += (s.size() - v[i].second + 1) * (v[i].first + 1 - val);
    val = v[i].first + 1;
  }
  cout << nb;
}
