#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
const int N=100005;
const int MOD=1e9+7;
int add (int x,int y)   {x=x+y;return x>=MOD?x-MOD:x;}
int mul (int x,int y)   {return (LL)x*y%MOD;}
int dec (int x,int y)   {x=x-y;return x<0?x+MOD:x;}
int Pow (int x,int y)
{
	if (y==0) return 1;
	if (y==1) return x;
	int lalal=Pow(x,y>>1);
	lalal=mul(lalal,lalal);
	if (y&1) lalal=mul(lalal,x);
	return lalal;
}
char ss[N];
int f[N];
int pos[N];
int pre[N][3];
int sum[N];
int suf[N][3];
int main()
{
	scanf("%s",ss+1);int n=strlen(ss+1);
	for (int u=1;u<=n;u++) sum[u]=(sum[u-1]+ss[u]-'a'+1)%3;
	pre[0][1]=pre[0][2]=1;pre[0][0]=-1;
	for (int u=1;u<=n;u++)
	{
		pre[u][0]=pre[u-1][0];
		pre[u][1]=pre[u-1][1];
		pre[u][2]=pre[u-1][2];
		pre[u][sum[u-1]]=u-1;
	}
	f[0]=1;
	for(int u=1;u<=n;u++) 
	{
		pos[u]=pos[u-1];
		if(ss[u]==ss[u-1]) pos[u]=u;
	}
	if (pos[n]==0)
	{
		printf("1\n");
		return 0;
	}
	f[0]=1;
	for(int u=1;u<=n;u++) 
	{
		int id=pos[u]-1;
		f[u]=f[u-1];
		int val=(ss[u]=='a')?2:1;
		if(~id) 
		{
		
			id=pre[id][(sum[u]-val+3)%3];
				//printf("YES!:%d\n",id);
			if(~id) f[u]=add(f[u],f[id]);
		}
		if(sum[u]==0&&u!=n) f[u]=add(f[u],1);
		
		//printf("%d %d %d\n",u,f[u],sum[u]);
	}
	printf("%d\n",f[n]);
	return 0;
}