The bear has a string *s* = *s*<sub class="lower-index">1</sub>*s*<sub class="lower-index">2</sub>... *s*<sub class="lower-index">|*s*|</sub> (record |*s*| is the string's length), consisting of lowercase English letters. The bear wants to count the number of such pairs of indices *i*, *j* (1 ≤ *i* ≤ *j* ≤ |*s*|), that string *x*(*i*, *j*) = *s*<sub class="lower-index">*i*</sub>*s*<sub class="lower-index">*i* + 1</sub>... *s*<sub class="lower-index">*j*</sub> contains at least one string "bear" as a substring.

String *x*(*i*, *j*) contains string "bear", if there is such index *k* (*i* ≤ *k* ≤ *j* - 3), that *s*<sub class="lower-index">*k*</sub> = *b*, *s*<sub class="lower-index">*k* + 1</sub> = *e*, *s*<sub class="lower-index">*k* + 2</sub> = *a*, *s*<sub class="lower-index">*k* + 3</sub> = *r*.

Help the bear cope with the given problem.
The first line contains a non-empty string *s* (1 ≤ |*s*| ≤ 5000). It is guaranteed that the string only consists of lowercase English letters.
#include "bits/stdc++.h"
using namespace std;

#define              ll              long long

#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()

#define            pb                push_back
#define          sz(a)               (int)a.size()
#define         fastio               ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define GR(a,n,m) vector<vector<int>> a(n, vector<int>(m));
#define fi first
#define se second

template<typename T>istream& operator>>(istream&I,vector<T>&v){for(auto&i:v)I>>i;return I;}
template<typename T>ostream& operator<<(ostream&O,vector<T>&v){for(auto&i:v)O<<i<<' ';return O;}
template<typename T>istream& operator>>(istream&I,vector<vector<T>>&v){for(auto&i:v)for(auto&x:i)I>>x;return I;}
template<typename T>ostream& operator<<(ostream&O,vector<vector<T>>&v){for(auto&i:v){for(auto&x:i)O<<x<<' ';O<<'\n';}return O;}
template<typename T,typename U>istream& operator>>(istream&I,pair<T,U>&p){I>>p.first>>p.second;return I;}
template<typename T,typename U>ostream& operator<<(ostream&O,pair<T,U>&p){O<<p.first<<' '<<p.second;return O;}


const int maxn = 1e5 + 3;
const ll mod = 1000000007;

int main()
{
   int i,j=0,k=0;
    string s;
    cin>>s;
    for(i=0; i<(int)s.size()-3; i++)
    {
        if(s.substr(i,4)=="bear")
        k=i+1;
        j+=k;
    }
    cout<<j<<endl;
 
}