#include<cstdio>
#include<cstring>
const int MOD=1e9+7;
char s[1000001];
int nxt[1000001];
int dp[1000001];
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);s[n+1]=s[n];
	for(int i=1,j=2;j<=n+1;j++){
		if(s[j-1]==s[j]){
			while(i<j)nxt[i++]=j;
		}
	}
	if(nxt[1]>n)printf("1");
	else{
		dp[0]=1;
		for(int i=0;i<n;i++){
			(dp[i+1]+=dp[i])%=MOD;
			(dp[nxt[i+1]]+=dp[i])%=MOD;
		}
		int ans=0;
		for(int i=n,j=0;i>0;i--){
			if(j%3==0)ans=(ans+dp[i])%MOD;
			j+=s[i]=='a'?1:2;
		}
		printf("%d",ans);
	}
}
