#include <bits/stdc++.h>
using namespace std;
int suf[5005];
int main() {
  string str;
  cin >> str;
  int ans = 0;
  int n = (int)str.length();
  suf[n - 1] = n;
  for (int i = n - 2; i >= 0; i--) {
    if (str.substr(i, 4) == "bear") {
      suf[i] = i;
    } else {
      suf[i] = suf[i + 1];
    }
  }
  for (int i = 0; i < (int)str.length(); i++) {
    if (suf[i] < n) ans += n - suf[i] - 3;
  }
  cout << ans << endl;
  return 0;
}
