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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=1e5+5,MOD=1e9+7;
inline int mod(int x){return x<MOD?x:x-MOD;}
set<int>st[3];
int n,nxt[MAXN],f[MAXN];
char s[MAXN];
int main() {
	scanf("%s",s+1);n=strlen(s+1);
	for(int i=1;i<=n;++i){
		bool flag=(s[1]!=s[2]);
		if(flag)for(int i=3;i<=n;i+=2)if(s[i]!=s[1]){flag=0;break;}
		if(flag)for(int i=4;i<=n;i+=2)if(s[i]!=s[2]){flag=0;break;}
		if(flag)return puts("1"),0;
	}
	for(int i=1,sum=0;i<=n;++i){if(s[i]=='a')sum=(sum+1)%3;else sum=(sum+2)%3;st[sum].insert(i);}
	nxt[n]=n+1;for(int i=n-1,p=n+1;i>=1;--i){if(s[i]==s[i+1])p=i+1;nxt[i]=p;}
	//for(int i=1;i<=n;++i)cout<<nxt[i]<<" ";cout<<endl;
	f[0]=1;
	for(int i=0,sum=0;i<n;(sum+=((s[++i]=='a')?1:2))%=3){
		//下一位是a
		if(s[i+1]=='a')f[i+1]=mod(f[i+1]+f[i]);
		else{
			int t=(sum+1)%3;
			set<int>::iterator it=st[t].lob(nxt[i+1]);
			if(it!=st[t].end())f[*it]=mod(f[*it]+f[i]);
		}
		//下一位是b
		if(s[i+1]=='b')f[i+1]=mod(f[i+1]+f[i]);
		else{
			int t=(sum+2)%3;
			set<int>::iterator it=st[t].lob(nxt[i+1]);
			if(it!=st[t].end())f[*it]=mod(f[*it]+f[i]);
		}
	}
	//for(int i=1;i<=n;++i)cout<<f[i]<<" ";cout<<endl;
	int ans=f[n];
	for(int i=n,sum=0;i>1;--i){
		(sum+=((s[i]=='a')?1:2))%=3;
		if(sum==0)ans=mod(ans+f[i-1]);
	}
	cout<<ans<<endl;
	return 0;
}