#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int tit = s.length();
  vector<pair<int, int> > pos;
  pos.push_back(make_pair(-1, -1));
  for (int i = 0; i < tit - 3; i++) {
    if (s[i] == 'b' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'r') {
      pos.push_back(make_pair(i, i + 3));
    }
  }
  pos.push_back(make_pair(s.length(), s.length()));
  int c = 0;
  for (int i = 0; i < pos.size() - 1; i++) {
    int temp = pos[i + 1].second - pos[i].first - 1;
    c += (temp * (temp - 1)) / 2;
  }
  for (int i = 0; i < pos.size() - 2; i++) {
    c -= 1;
  }
  int tot = (tit * (tit - 1)) / 2;
  cout << tot - c;
}
