#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define add(a,b) a=((a)+(b))%1000000007
#define mod 1000000007
#define ll long long
//#define file
using namespace std;

int b[100001],c[100001],n,i,j,k,l,ls;
char a[100002];
ll f[100001],g[100001],F[100001][3];

int main()
{
	#ifdef file
	freopen("agc027e.in","r",stdin);
	#endif
	
	scanf("%s",a+1),n=strlen(a+1);
	fo(i,1,n) b[i]=(b[i-1]+((a[i]=='a')?1:-1)+3)%3,c[i]=c[i-1]+(a[i]!=a[i+1]);
	
	ls=0;
	fo(i,1,n)
	{
		fo(j,0,2) F[i][j]=F[i-1][j];
		if (a[i-1]==a[i]) ls=i-1;
		
		if (i>1 && (b[i-1]+1)%3==b[i]) add(f[i],g[i-1]);
		else
		add(f[i],F[ls][(b[i]+2)%3]);
		if (b[i]==1 && (c[i-1]!=i-1 || i==1)) add(f[i],1);
		
		if (i>1 && (b[i-1]+2)%3==b[i]) add(f[i],g[i-1]);
		else
		add(f[i],F[ls][(b[i]+1)%3]);
		if (b[i]==2 && (c[i-1]!=i-1 || i==1)) add(f[i],1);
		
		if (c[i-1]==i-1) g[i]=(i+1)/2,f[i]=1; else g[i]=f[i];
		F[i][b[i]]=g[i];
	}
	printf("%lld\n",f[n]);
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}