#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  string s1 = "bear";
  int a[10000];
  int c = 0, sum(0);
  int n = s.size();
  for (int i = 0; i < n - 3; i++) {
    string s2 = s.substr(i, 4);
    if (s2 == "bear") {
      a[c] = i;
      if (c == 0) {
        sum += (i + 1) * (n - i - 3);
      } else {
        sum += (n - i - 3) * (i - a[c - 1]);
      }
      c++;
    }
  }
  cout << sum << endl;
  return 0;
}
