#include <bits/stdc++.h>
#define for1(a,b,i) for(int i=a;i<=b;++i)
#define FOR2(a,b,i) for(int i=a;i>=b;--i)
using namespace std;

#define M 100005
#define mod 1000000007
int n;
int f[M];
char a[M];
inline void inc(int &x,int y) {x+=y,x-=x>=mod?mod:0;}

int main () {
	//freopen("a.in","r",stdin);
	scanf("%s",a+1);
	n=strlen(a+1);
	bool t=0;
	for1(1,n-1,i) if(a[i]==a[i+1]) {t=1;break;}
	if(!t) return puts("1"),0;
	int ans=0;
	int s=0,pre[3]={0,-1,-1};
	f[0]=1;
	for1(1,n,i) {
		s=(s+2-(a[i]=='a'))%3;
		if(!s&&i<n) f[i]=1;
		++s,s%=3;
		if(pre[s]!=-1) inc(f[i],f[pre[s]]);
		++s,s%=3;
		if(pre[s]!=-1) inc(f[i],f[pre[s]]);
		++s,s%=3;
		pre[s]=i;
	}
	cout<<f[n]<<endl;
}