#include <bits/stdc++.h>
using namespace std;
char s[5005];
int n;
int main() {
  cin >> s;
  n = strlen(s);
  int pos = 0, 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 - pos + 1) * (n - (i + 3));
      pos = i + 1;
    }
  cout << ans;
  return 0;
}
