#include <bits/stdc++.h>
using namespace std;
int par[5020];
int bear[5020];
int find_sol(string s) {
  int k;
  par[0] = k = 0;
  for (int i = 1; i < ((int)s.size()); i++) {
    while (k > 0 && s[i] != s[k]) k = par[k - 1];
    if (s[i] == s[k]) k++;
    par[i] = k;
  }
  for (int i = 6; i < ((int)s.size()); i++) {
    bear[i - 5] = bear[i - 6] + (par[i] == 4);
  }
  int res = 0;
  int len = ((int)s.size()) - 5;
  for (int i = 0; i < len; i++) {
    for (int j = i + 3; j < len; j++) {
      if (i + 8 < ((int)s.size()) &&
          bear[j] - bear[i + 3] + (par[i + 8] == 4)) {
        res++;
      }
    }
  }
  return res;
}
int main() {
  string s, s2 = "bear";
  cin >> s;
  cout << find_sol(s2 + "#" + s) << endl;
  return 0;
}
