#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=100005;
const int mod=1e9+7;
int n,ans;
char s[maxn];
int sum[maxn],dp[maxn],nxt[maxn][3];

int main(){
	s[0]='$';scanf("%s",s+1);n=strlen(s)-1;
	REP(i,n)sum[i]=sum[i-1]+(s[i]-'a'+1);
	rep(j,3){
		nxt[n+1][j]=n+1;
		for(int i=n;i>=1;i--){
			nxt[i][j]=nxt[i+1][j];
			if(sum[i]%3==j)nxt[i][j]=i;
		}
	}
	dp[0]=1;
	int cur=1;
	REP(i,n){
		dp[i]+=dp[i-1];
		if(dp[i]>=mod)dp[i]-=mod;
		int c=(sum[i-1]+(s[i]=='a'?2:1))%3;
		cur=max(cur,i+1);
		while(cur<=n&&s[cur-1]!=s[cur])cur++;
		if(i==1&&cur==n+1){
			puts("1");
			return 0;
		}
		int j=nxt[cur][c];
		if(j<=n){
			dp[j]+=dp[i-1];
			if(dp[j]>=mod)dp[j]-=mod;
		}
	}
	REP(i,n)if((sum[n]-sum[i])%3==0){
		ans+=dp[i];
		if(ans>=mod)ans-=mod;
	}
	printf("%d\n",ans);
	return 0;
}