#include <bits/stdc++.h>
using namespace std;
string s;
vector<int> v;
int res;
int main() {
  cin >> s;
  int n = s.size();
  for (int i = 3; i < n; i++) {
    if (s[i - 3] == 'b' && s[i - 2] == 'e' && s[i - 1] == 'a' && s[i] == 'r')
      v.push_back(i - 3);
  }
  for (int i = 0; i < v.size(); i++) {
    if (!i) {
      res += (v[i] + 1) * (n - v[i] - 3);
    } else {
      res += (v[i] - v[i - 1]) * (n - v[i] - 3);
    }
  }
  cout << res;
  return 0;
}
