#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed=(b);i<=_ed;++i)
#define DREP(i,a,b) for(int i=(a),_ed=(b);i>=_ed;--i)
#define mp(x,y) make_pair((x),(y))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

const int N=1e5+5,mod=1e9+7;
int n,tr[N][3],f[N],sum[N];char s[N];
inline void inc(int& x,int y){x=x+y<mod?x+y:x+y-mod;}

/*
  s可以变成t当且仅当
  - t可以在s上分段表示出来(每个t中字符和s的每一段mod3同余,且s最后一段不匹配的mod3=0)
  - s存在两个相邻字符相同
  分段表示可以考虑贪心,用最短的去匹配(不算重)
 */
  
int main(){
	// freopen("in.in","r",stdin);
	scanf("%s",s+1);n=strlen(s+1);
	int flg=0;
	REP(i,2,n)if(s[i]==s[i-1])flg=1;
	if(!flg)return puts("1"),0;
	REP(i,1,n)sum[i]=(sum[i-1]+(s[i]=='a'?1:2))%3;
	REP(i,0,2)tr[n][i]=n+1;
	DREP(i,n-1,0){
		REP(j,0,2)tr[i][j]=tr[i+1][j];
		tr[i][sum[i+1]]=i+1;
	}
	f[0]=1;int ans=0;
	REP(i,0,n){
		REP(j,1,2)inc(f[tr[i][(sum[i]+j)%3]],f[i]);
		if(sum[i]==sum[n]&&i)inc(ans,f[i]);
	}
	printf("%d\n",ans);
	return 0;
}
