#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=1e5+20;
const int mod=1e9+7;

inline void pls(int &a,int b){ a+=b;if(a>=mod)a-=mod;}

int n;
char str[maxn];
int s[maxn];

int nxt[maxn][3],num[3];

inline void init()
{
	scanf("%s",str+1);
	n=strlen(str+1);
	REP(i,1,n)s[i]=(s[i-1]+str[i]-'a'+1)%3;
	REP(j,0,2)num[j]=n+1;
	DREP(i,n,0)
	{
		num[s[i]]=i;
		REP(j,0,2)nxt[i][j]=num[j];
	}
	int flg=1;
	REP(i,1,n-1)if(str[i]!=str[i+1]);else flg=0; 
	if(flg)puts("1"),exit(0);
}

int dp[maxn];
int ans=0;

inline void doing()
{
	dp[0]=1;
	REP(i,0,n-1)
	{
		REP(j,1,2)
		{
			int k=nxt[i+1][(s[i]+j)%3];
			if(k<=n)pls(dp[k],dp[i]);
		}
	}
	REP(i,1,n)if(s[i]==s[n])pls(ans,dp[i]);
	printf("%d\n",ans);
}

int main()
{
	init();
	doing();
	return 0;
}
