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