#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  int i = 0;
  stack<int> st;
  bool m = true;
  int sizee = (int)s.size();
  long long cnt = 0;
  while (1) {
    int temp = s.find("bear", i);
    if (temp == -1) {
      break;
    }
    i = temp + 1;
    int z = temp + 3;
    if (m) {
      m = false;
      cnt += (temp + 1) * (sizee - z);
    } else {
      cnt += (temp - st.top()) * (sizee - z);
    }
    st.push(temp);
  }
  cout << cnt;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
  return 0;
}
