#include <bits/stdc++.h>
using namespace std;
int i, j;
int main() {
  string str;
  int b = 0, e = 0, a = 0, r = 0, s = 0;
  cin >> str;
  if (str.size() >= 4)
    for (i = 0; i < str.size() - 3; i++) {
      for (j = i; j < str.size(); j++) {
        if (str[j] == 'b' && str[j + 1] == 'e' && str[j + 2] == 'a' &&
            str[j + 3] == 'r') {
          s = s + str.size() - j - 3;
          break;
        }
      }
    }
  cout << s;
}
