#include<bits/stdc++.h>

using namespace std;

#define N 300000

const int mod=1000000007;
int n,a[N],nxt[N],sum[N],f[N],ans;
char s[N];

void upd(int &x,int y){x=(x+y)%mod;}

int main(){
	scanf("%s",s+1); n=strlen(s+1);
	for (int i=n;i;--i){
		a[i]=s[i]=='a'?1:2;
		nxt[i]=a[i]==a[i+1]?i+1:nxt[i+1];
		sum[i]=(sum[i+1]+a[i])%3;
	}
	if (!nxt[1]){
		puts("1");
		return 0;
	}
	f[0]=1;
	for (int i=0;i<=n;++i){
		upd(f[i+1],f[i]);
		if (nxt[i+1]) upd(f[nxt[i+1]],f[i]);
		if (i&&!sum[i+1]) upd(ans,f[i]);
	}
	printf("%d\n",ans);
	
	return 0;
}
			