#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=100000 +117;
const int MM=100000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
int a[NN]={};
int xt[NN][3]={};
char in[NN]={};
LL dp[NN]={};
const int mod=1e9+7;
inline LL upd(LL &x,LL y){
	x=(x+y>=mod?x+y-mod:x+y);
}
int main(){
	//open();
	scanf("%s",in+1);
	n=strlen(in+1);
	bool fl=0;
	for(int i=1;i<=n;++i){
		a[i]=(in[i]=='a'?1:2);
		if(a[i]==a[i-1])fl=1;
	}
	for(int i=1;i<=n;++i){
		(a[i]+=a[i-1])%=3;
	}
	if(!fl){
		printf("1\n");
		return 0;
	}
	xt[n][0]=n+1;
	xt[n][1]=n+1;
	xt[n][2]=n+1;
	for(int i=n-1;i>=0;--i){
		for(int j=0;j<3;++j){
			xt[i][j]=xt[i+1][j];
		}
		xt[i][a[i+1]]=i+1;
	}
	dp[0]=1;
	for(int i=0;i<n;++i){
		for(int j=0;j<3;++j){
			if(j!=a[i]){
				upd(dp[xt[i][j]],dp[i]);
			}
		}
	}
	LL ans=0;
	for(int i=1;i<=n;++i){
		if(a[i]==a[n])upd(ans,dp[i]);
	}
	printf("%lld\n",ans);
	close();
	return 0;
}