#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int i = 0;
  int ans = 0;
  int n = s.size();
  int lx = -1;
  while (i < n) {
    int x = s.find("bear", i);
    if (x == string::npos) break;
    ans += (x - lx) * (n - x - 3);
    lx = x;
    i += 4;
  }
  cout << ans << "\n";
  return 0;
}
