#include<bits/stdc++.h>
#define rg register
#define oo 0x7fffffff
#define ll long long
using namespace std;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		{
			fh=-1;
			jp=getchar();
		}
	while (jp>='0'&&jp<='9')
		{
			out=out*10+jp-'0';
			jp=getchar();
		}
	return out*fh;
}
const int MAXN=1e5+10;
const int P=1e9+7;
inline int add(int a,int b)
{
	return (a + b) % P;
}
inline int mul(int a,int b)
{
	return 1ll * a * b  % P;
}
char s[MAXN];
int pre[MAXN],f[MAXN],nx[3];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",s);
	int n;
	int flag=0;
	for(;s[n];++n)
		{
			pre[n+1]=pre[n]+(s[n]=='a'? 1:2 );
			pre[n+1]%=3;
		}
	for(rg int i=1;i<n;++i)
		if(s[i]==s[i-1])
			flag=1;
	if(flag==0)
		{
			putchar('1');
			return 0;
		}
	f[n]=1;
	for(rg int i=0;i<3;++i)
		nx[i]=i==pre[n]?n:n+1;
	for(rg int i=n-1;i;--i)
		{
			f[i]= pre[i]==pre[n];
			for(rg int c=1;c<=2;++c)
				f[i]=add(f[i],f[nx[(pre[i]+c)%3]]);
			nx[pre[i]]=i;
		}
	cout<<add(f[nx[1]],f[nx[2]]);
	//fclose(stdin);
	//fclose(stdout);
	return 0;
}
