#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> a, pair<int, int> b) {
  return (a.first == b.first) ? a.second < b.second : a.first < b.first;
}
long long int modInverse(long long int a) {
  long long int m = 998244353;
  long long int y = 0, x = 1;
  while (a > 1) {
    long long int q = a / m;
    long long int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += 998244353;
  return x;
}
int x, l;
int main() {
  string s;
  cin >> s;
  for (int i = 0; s[i]; i++) {
    l = (s.substr(i)).find("bear");
    if (l != -1) x += s.size() - (i + 3 + l);
  }
  cout << x;
}
