#include <bits/stdc++.h>
using namespace std;
int main() {
  int k = 0, p = 0;
  long long summ = 0;
  string s;
  cin >> s;
  int* a = new int[s.length()];
  if (s.length() > 3)
    for (int i = 0; i < s.length() - 3; i++)
      if (s[i] == 'b' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'r')
        a[k++] = i + 1;
  for (int i = 0; i < k; i++) {
    summ += (a[i] - p) * (s.length() - a[i] - 2);
    p = a[i];
  }
  cout << summ;
  delete[] a;
  return 0;
}
