#include <bits/stdc++.h>
using namespace std;
string s;
int ans;
void solve() {
  if (s.size() > 3) {
    for (int i = 0; i <= s.size() - 4; i++) {
      int idx = s.find("bear", i);
      if (idx != -1) {
        ans += (s.size() - (idx + 4)) + 1;
      }
    }
  }
  cout << ans;
}
void read() { cin >> s; }
int main() {
  read();
  solve();
}
