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