#include <bits/stdc++.h>
using namespace std;
const int MAX_S = 5010;
bool good[MAX_S];
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  for (int i = 0; i <= (int)s.size() - 4; ++i) {
    if (s.substr(i, 4) == "bear") {
      good[i] = true;
    }
  }
  int ans = 0;
  int n = (int)s.size();
  for (int i = 0; i < n; ++i) {
    for (int j = i; j < n; ++j) {
      if (good[j]) {
        ans += n - (j + 3);
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
