#include<bits/stdc++.h>
#define mo 1000000007
#define N 100010
using namespace std;
string s;
int n,a[N],ne[N][4],dp[N],ans;
void add(int &x,int y){x+=y;if (x>=mo)x-=mo;}
int main(){
	cin>>s;n=s.length();
	for (int i=1;i<=n;i++)a[i]=(a[i-1]+s[i-1]-'a'+1)%3;
	ne[n+1][0]=ne[n+1][1]=ne[n+1][2]=ne[n+1][3]=n+1;
	for (int i=n;i>=1;i--){
		for (int j=0;j<=3;j++)ne[i][j]=ne[i+1][j];ne[i][a[i]]=i;
		if (i!=1&&s[i-1]==s[i-2])ne[i][3]=i;
	}
	if (ne[1][3]==n+1){puts("1");return 0;}
	dp[0]=1;
	for (int i=0;i<n;i++){
		add(dp[i+1],dp[i]);
		add(dp[ne[ne[i+2][3]][(a[i]+(3-s[i]+'a'-1))%3]],dp[i]);
	}
	for (int i=1;i<=n;i++)if (a[i]==a[n])add(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}