#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  if (argc == 2) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  set<pair<int, int> > visited;
  long long ans = 0;
  int n = s.length();
  for (int i = 0; i < s.length(); i++) {
    int ind = s.find("bear", i);
    if (ind != -1) ans += n - (ind + 3);
  }
  cout << ans << "\n";
}
