#include<bits/stdc++.h>
#define LL long long
#define db double

using namespace std;
const int N=1e5+10,mod=1e9+7;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}
char cc[N];
int n,k,f[N],c[3];

int main()
{
/////////ghdhdjfjhfjkghjgk
	scanf("%s",cc+1),n=strlen(cc+1);
	bool fg=1;
	for(int i=1;i<n;++i) fg&=cc[i]!=cc[i+1];
	if(fg){puts("1");exit(0);}
	f[0]=1;
	c[1]=c[2]=-1;
	for(int i=1;i<=n;++i)
	{
		k+=cc[i]-'a'+1,k%=3;
		if(!k&&i<n) f[i]=1;
		if(c[(k+1)%3]>=0) ad(f[i],f[c[(k+1)%3]]);
		if(c[(k+2)%3]>=0) ad(f[i],f[c[(k+2)%3]]);
		c[k]=i;
	}
	/*c[1]=c[2]=-1,f[0]=f[1]=1,s[0]=0,s[1]=cc[1]=='a'?1:2;
	k=1;
	while(k<n&&cc[k]!=cc[k+1]) ++k;
	for(int i=2,j=-1;i<=n;++i)
	{
		if(i<=k){f[i]=1;continue;}
		f[i]=f[i-1];
		s[i]=(s[i-1]+(cc[i]=='a'?1:2))%3;
		if(cc[i-1]==cc[i])
			while(j+1<i-1) ++j,itt(j);
		if(cc[i]=='a')
			if(c[(s[i]-2+3)%3]>=0) ad(f[i],g[c[(s[i]-2+3)%3]]);
		if(cc[i]=='b')
			if(c[(s[i]-1+3)%3]>=0) ad(f[i],g[c[(s[i]-1+3)%3]]);
		ad(f[i],z[(s[i]-1+3)%3]),ad(f[i],z[(s[i]-2+3)%3]);
		if(cc[i-1]==cc[i])
			while(j<i-1) ++j,itt(j);
		if(i>k+1&&j==k&&(bool)((s[i]-s[k]+3)%3)) ad(f[i],mod-f[k]);
		g[i]=f[i];
	}*/
	printf("%d\n",f[n]);
	return 0;
}
