#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int l = (int)s.length();
  int val[l], sz = 0, count = 0;
  for (int i = 0; i < l; i++) val[i] = -1;
  for (int i = 0; i < l; i++) {
    if (s[i] == 'b' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'r') {
      val[sz++] = i;
      i += 3;
    }
  }
  for (int i = 0; i < l; i++) {
    for (int j = 0; j < sz; j++) {
      if (i <= val[j]) {
        count += l - val[j] - 3;
        break;
      }
    }
  }
  cout << count << endl;
  return 0;
}
