#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  int c = 0, n = s.length(), k = -1;
  vector<int> v(1250);
  for (int i = 0; i < n - 3; i++)
    if (s[i] == 'b' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'r') {
      v[++k] = i;
      i += 3;
    }
  int ptr = 0, pre = -1;
  for (int i = 0; i < k + 1; i++) {
    c += (n - v[i] - 3) * (v[i] - pre);
    pre = v[i];
  }
  cout << c;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
