#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n,ok,ans;
const int N=100010,mod=1e9+7;
int sum[N],f[N],nt[N][3];
char s[N];
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
    for(int i=1;i<=n-1;++i)
    	if(s[i]==s[i+1]){ok=1;break;}
    if(!ok)return puts("1")==2333;
    
    for(int i=1;i<=n;++i)sum[i]=(sum[i-1]+(s[i]=='a'?1:2))%3;
	for(int i=0;i<=2;++i)nt[n][i]=n+1;
	for(int i=n-1;i>=0;--i)
	{
		for(int j=0;j<=2;++j)nt[i][j]=nt[i+1][j];
		nt[i][sum[i+1]]=i+1;
	}
	f[0]=1;
	for(int i=0;i<=n;++i)
	{
		for(int j=1;j<=2;++j)(f[nt[i][(sum[i]+j)%3]]+=f[i])%=mod;
		if(i&&sum[i]==sum[n])(ans+=f[i])%=mod;
	}
	cout<<ans;
	return 0;
}