#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long i, n = s.length();
  string a = "bear";
  long long j, f = 1, c = 0, k = 0;
  for (i = 0; i < n - 3; i++) {
    f = 1;
    for (j = 0; j < 4; j++) {
      if (s[i + j] != a[j]) {
        f = 0;
        break;
      }
    }
    if (f == 1) {
      if ((i + 1 - k) != 0)
        c += ((i + 1 - k) * (n - (i + j) + 1));
      else
        c += n - (i + j) + 1;
      k = i + 1;
      i += 3;
      continue;
    }
  }
  cout << c << "\n";
  return 0;
}
