#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int r = 0;
  for (int i = 0; i < s.size(); ++i) {
    auto it = s.find("bear", i);
    if (it != string::npos) {
      r += s.length() - it - 3;
    }
  }
  cout << r << endl;
}
