#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  string s;
  cin >> s;
  vector<pair<int, int>> v;
  int sum = 0;
  if (s.length() < 4) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < s.length() - 3; i++) {
    if (s[i] == 'b' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'r') {
      v.push_back({i, i + 3});
    }
  }
  for (int i = 0; i < v.size(); i++) {
    sum += (v[i].first + (i == 0 ? +1 : -v[i - 1].first)) *
           (s.length() - v[i].second);
  }
  cout << sum << endl;
  return 0;
}
