#include <bits/stdc++.h>
using namespace std;
vector<long long int> v;
int a[26];
int main() {
  long long int i, j, k, l, c = 0, prev = 0;
  string s;
  cin >> s;
  if (s.size() < 4) {
    cout << "0";
    return 0;
  }
  for (i = 0; i < s.size() - 3; i++) {
    if (s[i] == 'b' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'r') {
      c = c + (i + 1 - prev) * (s.size() - 3 - i);
      prev = i + 1;
    }
  }
  cout << c;
  return 0;
}
