#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const int N=1e5+10,mo=1e9+7;
int f[N],nex[N],n;
char s[N];
void move(int &a,int b){a=(a+b)%mo;}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	nex[n]=nex[n-1]=n+1;
	for (int i=n-2;~i;i--){
		nex[i]=nex[i+1];
		if (s[i+1]==s[i+2])nex[i]=i+2;
	}
	if (nex[0]==n+1){
		cout<<1<<endl;
		return 0;
	}
	f[0]=1;
	for (int i=0;i<n;i++)
		move(f[i+1],f[i]),
		move(f[nex[i]],f[i]);
	int cnt=0,ans=0,tag=0;
	for (int i=n;i>=1;i--){
		move(ans,(cnt%3==0)*f[i]),
		cnt+=(s[i]=='a')-(s[i]=='b');
	}
	cout<<ans<<endl;
}
