#include <bits/stdc++.h>
using namespace std;
bool compare(const pair<long long, long long> &a,
             const pair<long long, long long> &b) {
  return a.second > b.second;
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  long long i, j;
  string s;
  cin >> s;
  long long n = s.length();
  long long f = 1;
  if (n < 4) {
    cout << 0;
  } else {
    long long sm = 0;
    long long fsm = 0;
    for (i = 0; i < n - 3; i++) {
      if (s[i] == 'b' && s[i + 1] == 'e' && s[i + 2] == 'a' &&
          s[i + 3] == 'r') {
        sm = i + 1;
      }
      fsm += sm;
    }
    cout << fsm;
  }
}
