#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  long long i, len, x = 0, y = 0, z = 0, ans = 0;
  cin >> s;
  len = s.length();
  for (i = 0; i < len;) {
    if (s[i] == 'b') {
      x = i;
      i++;
      if (i < len && s[i] == 'e') {
        i++;
        if (i < len && s[i] == 'a') {
          i++;
          if (i < len && s[i] == 'r') {
            ans += ((x + 1) * (len - i));
            ans -= (y * (len - i));
            y = x + 1;
            i++;
          }
        }
      }
    } else
      i++;
  }
  cout << ans;
  return 0;
}
