#include <bits/stdc++.h>
using namespace std;
vector<int> prefix(string p, int m) {
  vector<int> f(m);
  int i = 1, j = 0;
  f[0] = 0;
  while (i < m) {
    if (p[i] == p[j]) {
      f[i] = j + 1;
      j++;
      i++;
    } else if (j > 0)
      j = f[j - 1];
    else {
      f[i] = 0;
      i++;
    }
  }
  return f;
}
vector<int> b, r;
int kmp(string s, int n, string p, int m) {
  int i = 0, j = 0;
  vector<int> f = prefix(p, m);
  while (i < n) {
    if (s[i] == p[j]) {
      if (j == m - 1) {
        b.push_back(i + 1);
        i++;
        j++;
      } else {
        i++;
        j++;
      }
    } else if (j > 0)
      j = f[j - 1];
    else
      i++;
  }
  return -1;
}
int main() {
  long long sum = 0;
  string s, p = "bear";
  cin >> s;
  kmp(s, ((int)((s).size())), p, ((int)((p).size())));
  for (int i = 0; i < ((int)((b).size())); ++i) {
    if (i == 0)
      sum += (b[i] - 3) * (1 + ((int)((s).size())) - b[i]);
    else
      sum += ((b[i] - 3) - (b[i - 1] - 3)) * (1 + ((int)((s).size())) - b[i]);
  }
  cout << sum;
}
