#include<stdio.h>
#include<string.h>
const int N=1e5+5,P=1e9+7;
char s[N];int n,m,p[N],g[N][3],f[N];
int main(){
	int x,c;
	scanf("%s",s+1),n=strlen(s+1);
	for(x=1;x<n;x++)if(s[x]==s[x+1])break;
	if(x<n){
		for(x=1;x<=n;x++)p[x]=(p[x-1]+(s[x]=='b')+1)%3;
		for(x=n;x>=0;x--)g[x][0]=g[x+1][0],g[x][1]=g[x+1][1],g[x][2]=g[x+1][2],g[x][p[x]]=x;
		f[0]=1;
		for(x=0;x<n;x++)if(f[x])for(c=0;c<3;c++)if(c!=p[x]&&g[x+1][c])f[g[x+1][c]]=(f[g[x+1][c]]+f[x])%P;
		for(x=1;x<=n;x++)if(p[x]==p[n])m=(m+f[x])%P;
	}else m=1;
	printf("%d\n",m);
}
