#include <bits/stdc++.h>
using namespace std;
int ans;
int main() {
  int ind = -1;
  char a[999999];
  cin >> a;
  if (strlen(a) >= 4) {
    for (auto i = 0; i < strlen(a) - 3; i++) {
      if (a[i] == 'b' && a[i + 1] == 'e' && a[i + 2] == 'a' &&
          a[i + 3] == 'r') {
        ind = i;
      }
      ans += ind + 1;
    }
  }
  cout << ans << endl;
  return 0;
}
