#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
#define Mod1(x) (x>=mod?x-mod:x)
#define Mod2(x) (x<0?x+mod:x)
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20];
	int len=0;
	if(x<0)putchar('-'),x=-x;
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
char s[maxn];
int sum[maxn],f[maxn];
int n;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	sum[0]=0;
	for(int i=1;i<=n;i++)
		sum[i]=(sum[i-1]+(s[i]=='a'?1:2))%3;
	int flag=0;
	for(int i=1;i<n;i++)
		if(s[i]==s[i+1])flag=1;
	if(!flag){
		puts("1"); return 0;
	}
	f[0]=1;
	int pos[3]={0,-1,-1};
	for(int i=1;i<=n;i++){
		f[i]=(!sum[i])&&(i<n);
		if(~pos[(sum[i]+1)%3])f[i]=(f[i]+f[pos[(sum[i]+1)%3]])%mod;
		if(~pos[(sum[i]+2)%3])f[i]=(f[i]+f[pos[(sum[i]+2)%3]])%mod;
		pos[sum[i]]=i;
		// printf("%d %d %d : %d %d %d\n",i,sum[i],f[i],pos[0],pos[1],pos[2]);
	}
	writeln(f[n]);
	return 0;
}