/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-15 15:38:40
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
const int N=100010,mod=1000000007;
char c[N];
int s,f[N],n,a[N],b[N];
int main()
{
	scanf("%s",c+1); n=strlen(c+1); f[n+1]=1;
	fr(i,1,n)
	{
		if(i==n){ printf("1\n"); return 0; }
		if(c[i]==c[i+1]) break;
	}
	fd(i,n,1)
	{
		a[i]=c[i]=='a'?i+1:c[i+1]=='b'?i+2:a[i+2];
		b[i]=c[i]=='b'?i+1:c[i+1]=='a'?i+2:b[i+2];
		s=(s+(c[i]=='a'?1:2))%3;
		f[i]=(f[a[i]]+f[b[i]]+(s==0))%mod;
//		printf("%d %d %d %d\n",i,a[i],b[i],f[i]);
	}
	printf("%d\n",(f[1]-(s==0)+mod)%mod);
	return 0;
}