using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 100010
#define ll long long
#define mo 1000000007
int n;
char s[N];
int sum[N][2];
int nxt[N][2][3];
int f[N];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for (int i=1;i<=n;++i)
		s[i]-='a';
	bool spj=1;
	for (int i=1;i<n && spj;++i)
		spj&=(s[i]!=s[i+1]);
	if (spj){
		printf("1\n");
		return 0;
	}
	for (int i=1;i<=n;++i){
		sum[i][0]=sum[i-1][0]+(s[i]==0);
		sum[i][1]=sum[i-1][1]+(s[i]==1);
	}
	nxt[n+1][0][0]=nxt[n+1][0][1]=nxt[n+1][0][2]=
	nxt[n+1][1][0]=nxt[n+1][1][1]=nxt[n+1][1][2]=n+1;
	for (int i=n;i>=1;--i){
		memcpy(nxt[i],nxt[i+1],sizeof nxt[i]);
		nxt[i][0][(sum[i][0]+i)%3]=i;
		nxt[i][1][(sum[i][1]+i)%3]=i;
	}
	f[0]=1;
	ll ans=0;
	for (int i=0;i<n;++i)
		for (int c=0;c<2;++c){
			int d=(sum[i][c^1]+i+1)%3,j=nxt[i+1][c^1][d];
			if (j<=n)
				(f[j]+=f[i])%=mo;
			if ((sum[n][c^1]+n)%3==(sum[i][c^1]+i+1)%3)
				(ans+=f[i])%=mo;
		}
//	for (int i=0;i<n;++i)
//		printf("%d ",f[i]);
//	printf("\n");
	printf("%lld\n",ans);
	return 0;
}