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