#include <bits/stdc++.h>
using namespace std;
string s;
vector<bool> ve(50001, 0);
int main() {
  getline(cin, s);
  int l = 0, r = 0, g = 0, cnt = 0;
  for (int i = 0; i < s.length();) {
    if (s[i] == 'b' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'r') {
      l = i + 1;
      r = i + 4;
      i += 4;
      for (int k = 1; k <= l; ++k) {
        g = r;
        while (g <= s.length() && !ve[k]) {
          ++cnt;
          ++g;
        }
        ve[k] = 1;
      }
    } else
      ++i;
  }
  cout << cnt;
  return 0;
}
