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