//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 300010
#define mdn 1000000007
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
char ch[N]; int lst[3],n,l[N],r[N],pre[N],f[N],s[N];
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
int query(int l,int r){return l>=0?(pre[r]-pre[l]+mdn)%mdn:pre[r];}
int main()
{
	scanf("%s",ch+1); n=strlen(ch+1); int flag=0;
	for(int i=1;i<n;i++)	flag|=(ch[i]==ch[i+1]);
	if(!flag)	return puts("1"),0;
	for(int i=1;i<=n;i++)	s[i]=s[i-1]+ch[i]-'a'+1;
	lst[1]=lst[2]=-1; int pt=-1;
	for(int i=1;i<=n;i++)
	{
		if(ch[i]==ch[i-1])	pt=i-2;
		r[i]=pt; l[i]=lst[s[i]%3]; lst[s[i]%3]=i;
	}
	f[0]=pre[0]=1;
	for(int i=1;i<=n;i++)
	{
		f[i]=f[i-1];
		if(l[i]<r[i]&&~r[i])	upd(f[i],query(l[i],r[i]));
		pre[i]=(pre[i-1]+f[i])%mdn;
	}
	int ans=0;
	for(int i=1;i<=n;i++)	if((s[n]-s[i])%3==0)	upd(ans,f[i]);
	printf("%d\n",ans);
	return 0;
}
