#include<bits/stdc++.h>
#define p 1000000007
char c[100010];int a[100010];
int f[100010],la[3];
int main(){
	scanf("%s",c+1);
	int n=strlen(c+1);bool fla=0;
	for(int i=1;i<=n;i++){
		a[i]=(a[i-1]+(c[i]=='b')+1)%3;
		if(c[i]==c[i-1])fla=1;
	}
	if(!fla)return putchar('1'),0;
	for(int i=1;i<=n;i++)(f[i]+=((long long)f[la[0]]+f[la[1]]+f[la[2]]+(a[i]>=1)-f[la[a[i]]])%p)%=p,la[a[i]]=i;
	printf("%d",f[n]);
	return 0;
}
