#include<bits/stdc++.h>
#define ll long long
#define ljc 1000000007
using namespace std;
char s[101010];
int n,suma[101010],sumb[101010],lasa[3],lasb[3]/*,nxta[101010],nxtb[101010]*/;
ll dp[101010];
vector<int> e[101010];
signed main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	bool flag=0;
	for (int i=1;i<n;i++){
		if (s[i]==s[i+1]){
			flag=1;break;
		}
	}
	if (!flag){
		puts("1");return 0;
	}
	for (int i=1;i<=n;i++){
		suma[i]=suma[i-1],sumb[i]=sumb[i-1];
		if (s[i]=='a') suma[i]++;
		else sumb[i]++;
	}
	memset(lasa,-1,sizeof lasa);
	memset(lasb,-1,sizeof lasb);
	int i;
	for (i=n;~i;i--){
		int aa=(2+i+suma[i])%3,bb=(2+i+sumb[i])%3;
		if (~lasa[aa]) e[lasa[aa]].push_back(i);
		if (~lasb[bb]) e[lasb[bb]].push_back(i);
		lasa[(i+suma[i])%3]=i,lasb[(i+sumb[i])%3]=i;
	}
	dp[0]=1;
	for (i=1;i<=n;i++){
		for (int j:e[i]) dp[i]=(dp[i]+dp[j])%ljc;
	}
	ll _=0;
	for (i=1;i<=n;i++){
		if (!((n+suma[n]-(suma[i]+i)%3)%3)) _=(_+dp[i])%ljc;
	}
	cout<<_;
	return 0;
}

