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