#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> s;
  long long len = s.size();
  long long res = 0;
  long long dem = -1;
  for (long long i = 0; i < len; i++) {
    if (s[i] == 'b' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'r') {
      res = res + (len - (i + 3)) * (i + 1) - ((dem + 1) * (len - (i + 3)));
      dem = i;
    }
  }
  cout << res << endl;
  return 0;
}
