#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=100005,mod=1000000007;
int nxt[N][2],dp[N],sum[N],Pos=N;
char ch[N];
vector<int> v[3];
inline void add(int &a,int b){
	a=a+b>=mod?a+b-mod:a+b;
}
signed main(){
	scanf("%s",ch+1);
	int n=strlen(ch+1);
	for(int i=1;i<=n;i++){
		ch[i]-='a'; ch[i]++;
		sum[i]=(sum[i-1]+ch[i])%3;
	}
	for(int i=1;i<=n;i++)v[sum[i]].push_back(i); ch[0]=-1;
	for(int i=n-1;i>=0;i--){
		if(ch[i+1]==ch[i])Pos=i;
		int t=(sum[i]+1)%3,pos=lower_bound(v[t].begin(),v[t].end(),Pos)-v[t].begin(); 
		if(sum[i+1]==t)nxt[i][0]=i+1; else if(pos<v[t].size())nxt[i][0]=v[t][pos];
		t=(t+1)%3; pos=lower_bound(v[t].begin(),v[t].end(),Pos)-v[t].begin();
		if(sum[i+1]==t)nxt[i][1]=i+1; else if(pos<v[t].size())nxt[i][1]=v[t][pos];
	}
	if(Pos>n){
		puts("1"); return 0;
	}
	dp[0]=1;
	for(int i=0;i<n;i++){
		if(nxt[i][0])add(dp[nxt[i][0]],dp[i]);
		if(nxt[i][1])add(dp[nxt[i][1]],dp[i]);
		//cout<<dp[i]<<" "<<nxt[i][0]<<" "<<nxt[i][1]<<endl;
	}
	for(int i=1;i<n;i++)if(sum[i]==sum[n])add(dp[n],dp[i]);
	cout<<dp[n]<<endl;
}
/*
aa/b/ab
aa/a/ab


*/
