#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, length, ans, koyta, arr[5001], arr1[5001];
  string str;
  cin >> str;
  length = str.length();
  k = 0;
  for (i = 0; i < length - 2; i++) {
    if (str[i] == 'b' && str[i + 1] == 'e' && str[i + 2] == 'a' &&
        str[i + 3] == 'r') {
      arr[k] = i;
      arr1[k++] = i + 3;
    }
  }
  ans = 0;
  length = str.size();
  for (i = 0; i < str.length(); i++) {
    for (j = 0; j < k; j++) {
      if (arr[j] >= i) {
        int last_indx = arr1[j];
        ans += (length - last_indx);
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
