#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
int f[N],s[N],nxt[N][3]; char c[N];
int main()
{	scanf("%s",c+1); int n=strlen(c+1),ans=0,tag=1;
	for(rint i=1;i<=n;i++) s[i]=(s[i-1]+1+(c[i]=='b'))%3,tag&=(c[i]!=c[i+1]);
	if(tag) return !printf("1");
	for(rint i=n;i>=1;i--)
	memcpy(nxt[i],nxt[i+1],sizeof(nxt[i])),nxt[i][s[i]]=i;
	f[nxt[1][1]]=f[nxt[1][2]]=1;
	for(rint i=1;i<=n;i++)
	{	for(rint j=1;j<=2;j++)
		if(nxt[i+1][(s[i]+j)%3]) (f[nxt[i+1][(s[i]+j)%3]]+=f[i])%=mod;
		if(s[n]==s[i]) (ans+=f[i])%=mod;
	}
	cout<<ans;
	return 0;
}
