#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define gc getchar
#define pc putchar
inline ll rd(){
    ll x=0,f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);puts("");}
const int maxn = 1e5+233;
const int mod = 1e9+7;
void add(int &x,int v){
	x+=v;
	if(x>=mod) x-=mod;
}
char t[maxn]; 
int n,ans,s[maxn],dp[maxn],nxt[maxn][3];
int main() {
	scanf("%s",t+1);n=strlen(t+1);
	bool flag=0;
	Rep(i,1,n-1) if (t[i]==t[i+1]) flag=1;
	if (!flag) return puts("1"),0;
	Rep(i,1,n) s[i]=t[i]-'a'+1;
	Rep(i,1,n+1) s[i]=(s[i]+s[i-1])%3;
	Rep(i,0,2) nxt[n+1][i]=n+1;
	Dep(i,n,1){
		Rep(j,0,2) nxt[i][j]=nxt[i+1][j];
		nxt[i][s[i]]=i;
	}
	dp[1]=1;
	Rep(i,1,n+1){
		Rep(k,1,2)
			if(nxt[i][(s[i-1]+k)%3] != n+1)
				add(dp[nxt[i][(s[i-1]+k)%3]+1],dp[i]);
		if(s[i-1]==s[n]&&i!=1) add(ans,dp[i]);
	}
	writeln(ans);
}

//0 1 2 3 4 5 
//0 1 2 0 1 X
