#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  vector<int> a;
  if (s.size() < 4) {
    cout << "0";
  } else {
    for (int i = 0; i < s.size() - 3; i++) {
      if (s[i] == 'b' && s[i + 1] == 'e' && s[i + 2] == 'a' &&
          s[i + 3] == 'r') {
        a.push_back(i);
      }
    }
    long long sum = 0;
    for (int i = 0; i < a.size(); i++) {
      if (i == 0) {
        sum += (s.size() - a[i] - 3) * (a[i] + 1);
      } else {
        sum += (s.size() - a[i] - 3) * (a[i] - a[i - 1]);
      }
    }
    cout << sum;
  }
  return 0;
}
