#include <bits/stdc++.h>
using namespace std;
inline void read(int &n) {
  int f = 1;
  n = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = n * 10 + ch - '0';
  n *= f;
}
inline void write(int n, char ch = '\n') {
  if (n < 0) {
    putchar('-');
    n = -n;
  }
  int st[30];
  int top = 0;
  do {
    st[++top] = n % 10;
    n /= 10;
  } while (n);
  while (top) putchar(st[top--] + '0');
  putchar(ch);
}
int main() {
  string s;
  cin >> s;
  int len = s.size(), ans = 0, pos = 0;
  for (int i = 0; i < len - 3; ++i) {
    if (s[i] == 'b' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'r') {
      ans += (i + 1) * (len - i - 3) - pos * (len - i - 3);
      pos = i + 1;
    }
  }
  write(ans);
  return 0;
}
