#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=1e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
#endif
}
int n;
char s[N];
void input()
{
	scanf("%s",s+1);
	n=strlen(s+1);
}
int sum[N],nex[N][3];
const int mo=1e9+7;
void add(int &x,int y)
{
	x+=y;x-=(x>=mo?mo:0);
}
int dp[N],ans;
void work()
{
	int flag=0;
	For(i,2,n)if(s[i]==s[i-1])flag=1;
	if(!flag){puts("1");return;}
	For(i,1,n)sum[i]=sum[i-1]+(s[i]-'a'+1);
	For(i,0,2)nex[n+1][i]=n+1;
	Fordown(i,n,1)
	{
		For(j,0,2)nex[i][j]=nex[i+1][j];
		nex[i][sum[i]%3]=i;
	}
	dp[0]=1;
	For(i,0,n)
	{
		For(j,1,2)
		{
			add(dp[nex[i+1][(sum[i]+j)%3]],dp[i]);
			//cout<<i<<' '<<nex[i+1][(sum[i]+j)%3]<<endl;
		}
		if(i&&sum[i]%3==sum[n]%3)add(ans,dp[i]);
	}
	write(ans,'\n');
}
int main()
{
//	file();
	input();
	work();
	return 0;
}
