#include <bits/stdc++.h>
using namespace std;
int main() {
  string b;
  cin >> b;
  int sum = 0;
  for (int i = 0; i < b.length(); i++) {
    if (b[i] == 'b') {
      if (b.substr(i, 4) == "bear" && i < b.length() - 3) {
        if (i >= 0) {
          int x = (b.length() - 1) - (i + 3);
          sum += (i * (x + 1));
          sum += x + 1;
          b = b.substr(i + 1, b.length() - i + 1);
          i = 0;
        }
      }
    }
  }
  cout << sum;
  return 0;
}
