#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(false);
  string s;
  cin >> s;
  int lastBear = -1;
  long long sum = 0;
  string bear = "bear";
  int lenb = bear.size();
  int lens = s.size();
  for (int i = 0; i <= lens - lenb; i++) {
    bool isBear = true;
    for (int j = 0; j < lenb; j++) {
      if (s[i + j] != bear[j]) {
        isBear = false;
        break;
      }
    }
    if (isBear) {
      long long firsts = i - lastBear;
      long long lasts = lens - (i + lenb - 1);
      lastBear = i;
      sum += firsts * lasts;
    }
  }
  cout << sum << endl;
  return 0;
}
