#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
const long long int M = 1e9 + 7;
const long double PI = 3.14159265;
using namespace std;
void solve() {
  long long int n, i, x, res = 0, j, k = 0;
  string str, s1 = "bear";
  cin >> str;
  n = str.length();
  for (i = 0; i < n; i++) {
    k = 0;
    for (j = i; j < n; j++) {
      if (k < 4) {
        if (str[j] == s1[k])
          k++;
        else {
          if (str[j] == s1[0])
            k = 1;
          else
            k = 0;
        }
      }
      if (k == 4) res++;
    }
  }
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  t = 1;
  while (t--) {
    solve();
  }
}
