#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
char s[100005];
int f[100005],nxt[100005][3],v[100005],db[100005];
inline void add(int &x,int y){
	x+=y;
	if(x>=mod)x-=mod;
}
int main(){
	scanf("%s",s+1);
	int l=strlen(s+1);
	for(int i=1;i<=l;i++)v[i]=(v[i-1]+s[i]-'a'+1)%3;
	for(int i=l;i>=1;i--){
		for(int j=0;j<3;j++)nxt[i][j]=nxt[i+1][j];
		nxt[i][v[i]]=i;
		db[i]=s[i]==s[i+1]?i+1:db[i+1];
	}
	if(!db[1]){puts("1"); return 0;}
	f[0]=1;
	for(int i=0;i<l;i++){
		for(int j=1;j<=2;j++){
			if(s[i+1]-'a'+1==j)add(f[i+1],f[i]);
			else if(db[i+1]&&nxt[db[i+1]][(v[i]+j)%3])add(f[nxt[db[i+1]][(v[i]+j)%3]],f[i]);
		}
	}
	int ans=0;
	for(int i=1;i<=l;i++)if(v[i]==v[l])add(ans,f[i]);
	printf("%d\n",ans);
	return 0;
}