#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size(), t = 0;
  for (int i = 0; i < n; i++) {
    int x = s.find("bear", i);
    if (x != -1) t += n - x - 4 + 1;
  }
  cout << t;
}
