#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=100005;
const int mo=1000000007;
int n,ans;
char s[N];
int las[N],S[N];
int suf[N][3],f[N];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	bool fl=0;
	For(i,1,n-1) if (s[i]==s[i+1]) fl=1;
	if (!fl) return puts("1"),0;
	For(i,1,n) S[i]=(S[i-1]+s[i]-'a'+1)%3;
	For(i,0,2) suf[n+1][i]=n+1;
	Rep(i,n,1){
		For(j,0,2)
			suf[i][j]=suf[i+1][j];
		suf[i][S[i]]=i;
	}
	f[0]=1;
	For(i,1,n+1){
		if (S[i-1]==S[n]&&i!=1) ans=(ans+f[i-1])%mo;
		int nx=suf[i+1][3-S[i-1]-S[i]];
		f[i]=(f[i]+f[i-1])%mo;
		f[nx]=(f[nx]+f[i-1])%mo;
	}
	printf("%d\n",ans);
}
/*
babba
baaa
bba
aa
b
*/