#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v;
  int sum = 0, x = 0, y = 0;
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++)
    if (s[i] == 'b' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'r')
      v.push_back(i + 1);
  for (int i = 0; i < v.size(); i++) {
    x = n - 1 - (v[i] + 2);
    if (i >= 1)
      y = (v[i] - v[i - 1]) - 1;
    else
      y = v[i] - 1;
    sum += x + y + x * y;
  }
  cout << sum + v.size();
}
