#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, s1;
  cin >> s;
  s1 = s;
  int l = s.length();
  int i = 0, j = 0, arr[6000] = {};
  long long int ans = 0, x;
  while (s.find("bear") != -1) {
    x = s.find("bear");
    s[x] = 'x';
    arr[j++] = x + 1;
  }
  for (i = 0; i < j; i++) {
    if (i >= 1)
      ans += (arr[i] - arr[i - 1]) * (l - (arr[i] + 3) + 1);
    else
      ans += (arr[i]) * (l - (arr[i] + 3) + 1);
  }
  cout << ans << endl;
  return 0;
}
