#include <bits/stdc++.h>
using namespace std;
int main() {
  string input;
  cin >> input;
  int final = 0, res = 0;
  if (input.size() < 4) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < input.size() - 3; i++) {
    if (input[i] == 'b' && input[i + 1] == 'e' && input[i + 2] == 'a' &&
        input[i + 3] == 'r') {
      for (int j = final; j < i + 1; j++)
        for (int h = i + 3; h < input.size(); h++) res++;
      final = i + 1;
    }
  }
  cout << res << endl;
  return 0;
}
