#include <bits/stdc++.h>
using namespace std;
long long i, j, m, n, p, q, r, ans, l, ch = 1;
string s;
int f;
vector<long long> v;
int main() {
  cin >> s;
  l = s.size();
  f = s.find("bear", 0);
  while (f >= 0) {
    p = f + 1;
    ch = abs(p - ch) + 1;
    q = p + 3;
    r = (l - q) + 1;
    ans += (r * ch);
    ch = p + 1;
    f = s.find("bear", ch);
  }
  cout << ans;
}
