#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
int main() {
  string s;
  cin >> s;
  long long total = 0;
  int last = -1;
  int n = s.size();
  for (int i = 0; i + 3 < s.size(); i++) {
    if (s[i] == 'b' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'r') {
      int left = i - last;
      last = i;
      int right = n - (i + 3);
      total += (left * right);
    }
  }
  cout << total << endl;
}
