#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second

#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2

#define INF ((1ll<<60)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")
using namespace std;

const int mo=1000000007;
const int N=100005;
int a[N],nxt[N][3];
int ans,f[N];
char s[N];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1),fl=0;
	For(i,1,n-1) if (s[i]==s[i+1]) fl=1;
	if (!fl) return puts("1"),0;
	For(i,1,n) a[i]='c'-s[i];
	For(i,1,n+1) a[i]+=a[i-1],a[i]%=3;
	For(i,0,2) nxt[n+1][i]=n+1;
	Rep(i,n,0){
		For(j,0,2) nxt[i][j]=nxt[i+1][j];
		nxt[i][a[i]]=i;
	}
	f[1]=1;
	For(i,1,n+1){
		if (nxt[i][(a[i-1]+1)%3]!=n+1)
			(f[nxt[i][(a[i-1]+1)%3]+1]+=f[i])%=mo;
		if (nxt[i][(a[i-1]+2)%3]!=n+1)
			(f[nxt[i][(a[i-1]+2)%3]+1]+=f[i])%=mo;
		if (a[i-1]==a[n]&&i!=1) (ans+=f[i])%=mo;
	}
	printf("%d\n",ans);
}