#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  queue<int> pos;
  int arr[n];
  arr[0] = 0;
  int lastb = -1;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'b') {
      if (i + 3 < n) {
        if (s.substr(i, 4) == "bear") {
          pos.push(i);
          lastb = i;
        }
      }
    }
    if (i > 0) {
      arr[i] = arr[i - 1];
    }
    if (s[i] == 'r') {
      if (lastb != -1 && i - lastb <= 3) {
        arr[i] = arr[i - 1] + 1;
      }
    }
  }
  int k = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (!pos.empty() && i > pos.front()) {
      k++;
      pos.pop();
    }
    for (int j = i + 1; j < n; j++) {
      if (arr[j] - k > 0) {
        ans++;
      }
    }
  }
  cout << ans;
}
