#include <bits/stdc++.h>
using namespace std;
vector<int> v;
char s[12345];
int main() {
  scanf("%s", s);
  char y[] = "bear";
  int ind = 0;
  string x = "";
  v.push_back(-1);
  for (int i = 0; s[i]; i++) {
    if (s[i] == y[ind]) {
      x += y[ind++];
    } else {
      if (s[i] == 'b') {
        ind = 1;
        x = "b";
      } else {
        ind = 0;
        x = "";
      }
    }
    if (x == "bear") {
      x = "";
      v.push_back(i - 3);
      ind = 0;
    }
  }
  long long ans = 0;
  int len = strlen(s);
  for (int i = 1; i < (int)v.size(); i++) {
    int m = len - v[i] - 3;
    ans += (long long)m * (v[i] - v[i - 1]);
  }
  printf("%I64d\n", ans);
  return 0;
}
