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