#include<bits/stdc++.h>
#define SZ(x) ((int)x.size())
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
const int N = 233333,mo=1e9+7;
char S[N];int n,f[N],s[N],qz[N],b[N],res,ok[N];vector<int> a[3];
void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}

int main(){
	scanf("%s",S+1);n=strlen(S+1);rep(i,1,n)s[i]=S[i]-'a'+1;
	rep(i,1,n)qz[i]=(qz[i-1]+s[i])%3,a[qz[i]].push_back(i);f[0]=1;
	for(int i=n,j=n+1;i>=0;i--){if(s[i]==s[i+1])j=i+1;b[i]=j;}
	rep(i,1,n)ok[i]=b[i]<=n&&(qz[n]-qz[i-1])%3;ok[n]=1;
	if(b[1]>n){puts("1");return 0;}
	rep(i,0,n-1)rep(j,1,2){
		if(s[i+1]==j)add(f[i+1],f[i]);
		else if(SZ(a[(qz[i]+j)%3])&&b[i+1]<=a[(qz[i]+j)%3].back()){//RE
			int k=*lower_bound(a[(qz[i]+j)%3].begin(),a[(qz[i]+j)%3].end(),b[i+1]);
			if(k<=n)add(f[k],f[i]);
		}
	}
//	rep(i,0,n)printf("%d:%d\n",i,f[i]);
	res=0;rep(i,1,n)if((qz[n]-qz[i])%3==0)add(res,f[i]);
	printf("%d",res);
	return 0;
}