#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const int inf = LONG_MAX;
struct pt {
  int x, y;
};
int ans = 0, n, lb = -1;
string s;
bool bh(int j) {
  if (s.substr(j - 3, 4) == "bear")
    return true;
  else
    return false;
}
int main() {
  cin >> s;
  n = s.length();
  for (int i = 3; i <= n - 1; i++) {
    if (bh(i)) {
      lb = i - 3;
      ans += lb + 1;
    } else {
      if (lb != -1) ans += lb + 1;
    }
  }
  cout << ans;
}
