#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int N=100005,P=1e9+7;
int n,f[N],nxt[N][2];char s[N];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	bool flg=0;
	rep(i,1,n-1)if(s[i]==s[i+1])flg=1;
	if(!flg)puts("1"),exit(0); 
	f[n+1]=1;
	nxt[n+1][0]=nxt[n+1][1]=nxt[n+2][0]=nxt[n+2][1]=n+2;
	int sum=0;
	per(i,n,1){
		(sum+=s[i]-'a'+1)%=3;
		nxt[i][0]=(s[i]=='a'?i+1:s[i+1]=='b'?i+2:nxt[i+2][0]);
		nxt[i][1]=(s[i]=='b'?i+1:s[i+1]=='a'?i+2:nxt[i+2][1]);
		f[i]=(f[nxt[i][0]]+f[nxt[i][1]]+(sum==0))%P;
	}
	printf("%d\n",(f[1]-(sum==0)+P)%P);
	return 0;
}