#include <bits/stdc++.h>
using namespace std;
int main() {
  int i = 0, j, k, l, pairs = 0, oldl;
  string s, s2;
  cin >> s;
  l = s.size();
  std::size_t found;
  oldl = l;
  while (s.size() > 0) {
    l = s.size();
    found = s.find("bear");
    if (found != std::string::npos) {
      pairs += ((found + 1) * (l - (found + 3)));
      s = s.substr(found + 1);
    } else
      break;
    oldl = l;
  }
  printf("%d\n", pairs);
  return 0;
}
