#include <bits/stdc++.h>
using namespace std;
ifstream fin("A.in");
ofstream fout("A.out");
string s;
int cnt = 0;
int v[5011][5011];
int main() {
  cin >> s;
  int n = s.length();
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'b' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'r') {
      v[i + 1][i + 4] = 1;
    }
  }
  for (int i = 3; i < n; ++i) {
    for (int j = 1; j + i <= n; ++j) {
      if (v[j][i + j]) {
        ++cnt;
        v[j - 1][i + j] = 1;
        v[j][i + j + 1] = 1;
      }
    }
  }
  cout << cnt;
}
