#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define N 100010
char s[N];
int S[N],ne[N][4],f[N],ans;
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1); bool flag=1;
	for (int i=2;i<=n && flag;i++) if (s[i]==s[i-1]) flag=0;
	if (flag) {puts("1"); return 0;}
	for (int i=1;i<=n;i++) S[i]=(S[i-1]+s[i]-'a'+1)%3;
	ne[n][0]=ne[n][1]=ne[n][2]=n+1;
	for (int i=n-1;i>=0;i--){
		for (int j=0;j<3;j++) ne[i][j]=ne[i+1][j];
		ne[i][S[i+1]]=i+1;
	}
	f[0]=1;
	for (int i=0;i<n;i++){
		if (!f[i]) continue;
		for (int k=0;k<3;k++){
			if (S[i]==k) continue;
			if (ne[i][k]>n) continue;
			(f[ne[i][k]]+=f[i])%=M;
		}
		if (i && S[i]==S[n]) (ans+=f[i])%=M;
	}
	(ans+=f[n])%=M;
	printf("%d\n",ans);
	return 0;
}