#include<cstdio>
#include<cstring>
#define N 100005
#define p 1000000007
inline int _a(int x){return x<3?x:x-3;}
inline int _b(int x){return x<p?x:x-p;}
char c[N];int a[N],b[N][3],f[N],i,j,n,o[3],x;
int main()
{
    scanf("%s",c+1),n=strlen(c+1),o[0]=o[1]=o[2]=b[n+1][0]=b[n+1][1]=b[n+1][2]=n+1,*f=1;
    for(i=1;i<=n;i++)a[i]=_a(a[i-1]+(c[i]==97?1:2));
    for(i=1;i<n&&c[i]!=c[i+1];i++);
    if(i==n)return 0&puts("1");
    for(i=j=n;i;b[i][_a(3-a[i-1])]=o[0],b[i][_a(4-a[i-1])]=o[1],b[i][_a(5-a[i-1])]=o[2],b[i][c[i]==97?1:2]=i,i--)if(c[i]==c[i+1])while(i<j)o[a[j]]=j,j--;
    for(i=0;i<=n;i++)f[b[i+1][1]]=_b(f[b[i+1][1]]+f[i]),f[b[i+1][2]]=_b(f[b[i+1][2]]+f[i]);
    for(i=1;i<=n;i++)if(a[i]==a[n])x=_b(x+f[i]);
    return 0*printf("%d\n",x);
}