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