// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int maxn=100111;
const int mod=1e9+7;
inline void add(int&x,int y){x+=y;if(x>=mod)x-=mod;}

char s[maxn];int n,pre[maxn],dp[maxn],nxt[maxn][3];

int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	bool have=0;for(int i=1;i<n;i++)if(s[i]==s[i+1])have=1;
	
	if(!have)
	{
		puts("1");
		return 0;
	}
	
	for(int i=1;i<=n;i++)if(s[i]=='a')pre[i]=(pre[i-1]+1)%3;else pre[i]=(pre[i-1]+2)%3;
	for(int i=0;i<3;i++)nxt[n+1][i]=n+1;
	for(int i=n;i>=1;i--)
	{
		memcpy(nxt[i],nxt[i+1],sizeof(nxt[i]));
		nxt[i][pre[i]]=i;
	}
	dp[0]=1;
	for(int i=0;i<n;i++)
	{
		for(int k=1;k<=2;k++)
			add(dp[nxt[i+1][(pre[i]+k)%3]],dp[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++)if(pre[i]==pre[n])add(ans,dp[i]);
	printf("%d\n",ans);
	return 0;
}