#include<bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::mt19937 rnd(time(NULL));
#define rand rnd
#define pr std::pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
template<class T>void cxk(T&a,T b){a=a>b?a:b;}
template<class T>void cnk(T&a,T b){a=a<b?a:b;}
#ifdef mod
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
template<class Ta,class Tb>void inc(Ta&a,Tb b){a=a+b>=mod?a+b-mod:a+b;}
template<class Ta,class Tb>void dec(Ta&a,Tb b){a=a>=b?a-b:a+mod-b;}
#endif
char S[100010];
int f[100010],lst[100010][3];
int main(){
#ifdef LOCAL
	freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	scanf("%s",S+1);int n=strlen(S+1);
	int R=1;while(R<n&&S[R+1]!=S[R])++R;
	for(int j=0;j<3;++j)lst[0][j]=-1;
	for(int i=1,s=0,L=0;i<=n;++i){
		for(int j=0;j<3;++j)lst[i][j]=lst[i-1][j];
		lst[i][s]=i-1;
		s=(s+S[i]-'a'+1)%3;
		if(S[i]==S[i-1])L=i-1;
		int p=lst[L][(s+1)%3],q=lst[L][(s+2)%3];
		if(S[i]=='b')p=i-1;else q=i-1;
		if(~p){
			inc(f[i],f[p]);
			if(p&&p<=R&&R<i)inc(f[i],p-1>>1);
		}
		if(~q){
			inc(f[i],f[q]);
			if(q&&q<=R&&R<i)inc(f[i],q-1>>1);
		}
		if(s&&(i==1||i>R))inc(f[i],1);
	}
	printf("%d\n",f[n]);
	return 0;
}
