#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int len, i, t = 0, cnt = 0, sum = 0;
  len = s.length();
  int b[5000];
  memset(b, 0, sizeof(b));
  for (i = 0; i < len - 3; i++) {
    if (s[i] == 'b' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'r') {
      b[t++] = i;
    }
  }
  cnt = t;
  if (cnt == 0)
    cout << 0;
  else {
    sum = (b[0] + 1) * (len - 3 - b[0]);
    for (i = 1; i < cnt; i++) sum = sum + (b[i] - b[i - 1]) * (len - 3 - b[i]);
    cout << sum;
  }
  return 0;
}
