#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 100010;
const int INF = 2147483600;

int nxt[MAXN+1][3];
LL f[MAXN+1]; char str[MAXN+1];
int a[MAXN+1];
LL sum;

inline int Tns(int x){
	return (x==2?1:2);
} int N; 
const int Mod = 1000000007LL;
LL s[MAXN+1]; int To[MAXN+1];

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",str+1); bool pt=0; f[0]=1; N=strlen(str+1);
	for(int i=1;i<=N;i++) a[i]=(int)(str[i]-'a')+1,s[i]=s[i-1]+a[i]; 
	for(int i=N;i>=1;i--){
		nxt[i][1]=nxt[i+1][(1-a[i]+3)%3];
		nxt[i][2]=nxt[i+1][(2-a[i]+3)%3];
		nxt[i][0]=nxt[i+1][(3-a[i])%3];
		nxt[i][a[i]]=i; To[i]=To[i+1]; if(a[i]==a[i+1]) To[i]=i+1,pt=1;
	} if(!pt){
		puts("1"); return 0;
	}
	for(int i=1;i<=N;i++){
		(f[i]+=f[i-1])%=Mod; sum+=a[i];
		int d=(3+Tns(a[i])-(s[To[i]]-s[i-1])%3)%3;
		if(To[i]&&(nxt[To[i]+1][d]||!d)) 
			(f[(!d?To[i]:nxt[To[i]+1][d])]+=f[i-1])%=Mod;
	} LL ans=0; bool vis=0; sum=0;
	for(int i=N;i>=1;i--){
		if(!(sum%3)) (ans+=f[i])%=Mod;
		sum+=a[i];
	} printf("%lld\n",ans);
	return 0;
}


