#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define ref(i,x,y)for(int i=x;i<=y;++i)
#define def(i,x,y)for(int i=x;i>=y;--i)
int read(){char c=getchar();int d=0,f=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')f=-1;for(;c>='0'&&c<='9';d=d*10+c-48,c=getchar());return d*f;}
char Read(){char c=getchar();while(c<'0'||c>'9')c=getchar();return c;}
typedef pair<int,int>PII;
typedef long long LL;
const int N=100000;
const int mod=1e9+7;
int n,dp[N+1],a[N+1],t[N+1][3],tt[N+1],p[10];
char s[N+1];
int main(){
	scanf("%s",s+1); n=strlen(s+1);
	ref(i,1,n)a[i]=(s[i]=='a'?1:2);
	ref(i,1,n)(a[i]+=a[i-1])%=3;
	def(i,n,1){
		ref(j,0,2)t[i][j]=t[i+1][j]; t[i][a[i]]=i;
		tt[i]=tt[i+1]; if(i<n&&s[i]==s[i+1])tt[i]=i+1;
	}
	dp[0]=1;
	ref(i,0,n-1)if(dp[i]){
		p[0]=0;
		p[++p[0]]=i+1;
		if(tt[i+1])ref(j,0,2) if(j!=a[i]&&j!=a[i+1])p[++p[0]]=t[tt[i+1]][j];
		if(tt[i+1]&&a[n]!=a[i]){ p[++p[0]]=n; ref(j,1,p[0]-1)if(p[j]==n)p[0]--; }
		ref(j,1,p[0])(dp[p[j]]+=dp[i])%=mod;
		if(i&&i!=n-1&&!tt[i+1]){
			int S=(s[i]!=s[i+1])?(mod+dp[i]-dp[i-1]):dp[i];
			S=1LL*S*((n-i-1)/2)%mod;
			(dp[n]+=S)%=mod;
		}
	}
	cout<<dp[n]<<endl;
}