#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s, temp = "";
  cin >> s;
  long long i, j, sum = 0, count = 0;
  for (i = 3; i < s.length(); i++) {
    temp = "";
    for (j = i; j >= i - 3; j--) temp += (s[j]);
    reverse(temp.begin(), temp.end());
    if (temp == "bear") {
      sum = sum + (s.length() - i) + (i - 3 - count) * (s.length() - i);
      count = (i - 2);
    }
  }
  cout << sum << endl;
}
