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