#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define p 1000000007
#define file(x)freopen(x".in","r",stdin);freopen(x".out","w",stdout)
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x=0;char zf=1;char ch=getchar();
    while(ch!='-'&&!isdigit(ch))ch=getchar();
    if(ch=='-')zf=-1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int k,m,n,x,y,z,cnt,ans;
char c[100010];int a[100010];
int f[100010],la[100010][3];
int main(){
	scanf("%s",c+1);n=strlen(c+1);
	la[0][1]=la[0][2]=0;
	for(rt i=1;i<=n;i++){
		la[i][0]=la[i-1][0],la[i][1]=la[i-1][1],la[i][2]=la[i-1][2];
		a[i]=(a[i-1]+(c[i]=='b')+1)%3;la[i][a[i]]=i;
	}
	bool fla=0;
	for(rt i=2;i<=n;i++)if(c[i]==c[i-1])fla=1;
	if(!fla)return cout<<1,0;
	bool vis[3]={0,0,0};
	for(rt i=1;i<=n;i++){
		if(a[i])f[i]=1,vis[a[i]]=1;
	}
	for(rt i=1;i<=n;i++){
		f[i]+=((ll)f[la[i][0]]+f[la[i][1]]+f[la[i][2]]-f[la[i][a[i]]])%p;
		(f[i]+=p)%=p;
	}
	cout<<f[n];
	return 0;
}
