#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, ls;
  char s[5001];
  cin >> s;
  ls = strlen(s);
  for (int i = 0; i < (ls - 3); i++) {
    for (int j = i; j < ls; j++) {
      if (s[j] == 'b' && s[j + 1] == 'e' && s[j + 2] == 'a' &&
          s[j + 3] == 'r') {
        n += (ls - (j + 3));
        j = ls;
      }
    }
  }
  cout << n;
  return 0;
}
