#include<bits/stdc++.h>
#define gc getchar()
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
const int mod = 1e9+7,base=3;
inline int read(){char ch=gc;int w=1,s=0;while(!isdigit(ch)){if(ch=='-') w=-1;ch=gc;};while(isdigit(ch)){s=s*10+ch-'0';ch=gc;} return w*s;}
int Sum[1000100],A[1000010],n,nxt[1000100][3];
int f[1000010];
char ch[1000010]; 
inline int add(int a,int b){a+=b;if(a>=mod) a-=mod;return a;}
int main()
{
	scanf("%s",ch+1);n=strlen(ch+1);
	int fl=0;
	for(rint i=1;i<=n;++i) A[i]=ch[i]=='a'?1:2;
//	for(rint i=1;i<=n;++i) cout<<A[i]<<"\n";
	for(rint i=1;i<=n;++i) Sum[i]=(Sum[i-1]+A[i])%base;
	for(rint i=1;i<n;++i) if(A[i]==A[i+1]) fl=1;
	if(!fl)
	{
	//	cout<<1<<"\n";
		cout<<"1";return 0;
	}
	for(rint i=n;i;--i) memcpy(nxt[i],nxt[i+1],sizeof(nxt[i+1])),nxt[i][Sum[i]]=i;
	f[0]=1;
	for(rint i=0;i<n;++i)
	{
		for(rint j=0;j<base;++j)
		{
			if(j!=Sum[i])
			{
				int tmp=nxt[i+1][j];
				if(tmp) f[tmp]=add(f[i],f[tmp]);
			}
		}
	}int res=0;
	for(rint i=1;i<=n;++i) if(Sum[i]==Sum[n]) res=add(res,f[i]);
	cout<<res<<"\n";
	return 0;
}
/*
by was_n
2018.9.17
*/

