#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <queue> //CF226 div2 B
#define LL long long
#define inf 999999999
using namespace std;
char a[5100], p[5]="bear";
int main()
{
int n, t, j, k;
LL s;
while(scanf("%s", a)!=EOF)
{
n=strlen(a);
for(j=k=0, s=0; j<n-3; ++j)
{
for(t=0; t<4; ++t)
{
if(a[j+t]!=p[t])break;
}
if(t==4)
{
s+=LL((j-k+1)*(n-j-3));
k=j+1;
}
}
printf("%I64d\n", s);
}
return 0;
}
CF226 div2 B
最新推荐文章于 2021-08-23 14:30:41 发布