#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  int count = 0;
  int last = 0, cur = 0, late = 0, flag = 0, lastflag = flag, check = 0;
  int len = a.size();
  for (int i = 0; a[i] != '\0'; i++) {
    if (a[i] == 'b' && a[i + 1] == 'e' && a[i + 2] == 'a' && a[i + 3] == 'r') {
      if (check == 0) {
        count = count + (len - (i + 3));
        if (i != 0) count += i * (len - (i + 3));
        check += 1;
      };
      cur = i;
      late = len - (i + 3);
      if (flag != 0) {
        count = count + ((cur - last) * late);
      }
      flag++;
    }
    if (lastflag != flag) {
      last = i;
    }
    lastflag = flag;
  }
  cout << count;
  return 0;
}
