#include<bits/stdc++.h>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

const int N = 1e5+5;
const int mo = 1e9+7;

char s[N];
int n;
int a[N];
int suf[N][3];
int w[N];
int f[N];

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	bool pd=1;
	fo(i,2,n)pd&=(s[i]!=s[i-1]);
	if (pd)return printf("1\n"),0;
	fo(i,1,n){
		a[i]=s[i]-'a'+1;
	}
	fo(i,1,n)a[i]=(a[i]+a[i-1])%3;
	fd(i,n,0){
		suf[i][0]=w[0];
		suf[i][1]=w[1];
		suf[i][2]=w[2];
		w[a[i]]=i;
	}
	f[0]=1;
	fo(i,0,n-1){
		//a
		int v=(a[i]+1)%3;
		if (suf[i][v])f[suf[i][v]]=(f[suf[i][v]]+f[i])%mo;
		v=(a[i]+2)%3;
		if (suf[i][v])f[suf[i][v]]=(f[suf[i][v]]+f[i])%mo;
	}
	int ans=0;
	bool ext=0;
	fo(i,1,n)
	if (a[i]==a[n])ans=(ans+f[i])%mo;
	cout<<ans<<endl;
	return 0;
}