#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define N 100012
#define mod 1000000007
inline int M(int x){return (x>=mod)?(x-mod):x;}
inline void Add(int &x,int v){x=M(x+v);}
inline int M1(int x){return (x<0)?(x+mod):x;}
inline int ksm(int p,int k){int res=1;while(k){if(k&1)res=1ll*res*p%mod;k>>=1;p=1ll*p*p%mod;}return res;}
int n,s[N],R[N],V[N],f[N],ne[N][3],now[3],tr[N][3],ans=0;char sc[N];
int main(){
	scanf("%s",sc+1);n=strlen(sc+1);int i,j,v;
	for(i=1;i<=n;i++)s[i]=(s[i-1]+sc[i]-'a'+1)%3;R[n]=n;for(i=n-1;i>=1;i--)R[i]=(sc[i]==sc[i+1])?i:R[i+1];if(R[1]==n){printf("1");return 0;}
	for(i=1;i<=n+1;i++){memcpy(ne[i],ne[i-1],sizeof(ne[i-1]));ne[i][s[i-1]]=i-1;}
	now[0]=now[1]=now[2]=n+1;for(i=n;i>=1;i--){for(j=0;j<=2;j++)while(ne[now[j]][j]>R[i])now[j]=ne[now[j]][j];memcpy(tr[i],now,sizeof(now));}
	f[0]=1;for(i=0;i<n;i++)if(v=f[i]){Add(f[i+1],v);Add(f[tr[i+1][(2-sc[i+1]+'a'+s[i])%3]],v);}
	for(i=1;i<=n;i++)if(s[n]==s[i])ans=M(ans+f[i]);printf("%d",ans);return 0;
}