#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const int MOD=1e9+7;

int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}

int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}

int nxt[111111];
int dp[111111][2];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin>>s; int n=s.length(); s="$"+s;
	nxt[n]=-1;
	for(int i=n-1;i>=1;i--)
	{
		nxt[i]=-1;
		if(s[i+1]==s[i]) {nxt[i]=i+1; continue;}
		nxt[i]=nxt[i+1];
	}
	nxt[0]=nxt[1];
	dp[0][0]=1; 
	for(int i=0;i<n;i++)
	{
		int v=add(dp[i][0],dp[i][1]);
		dp[i+1][s[i+1]-'a']=add(dp[i+1][s[i+1]-'a'],v);
		if(nxt[i+1]>0) dp[nxt[i+1]][(s[i+1]-'a')^1]=add(dp[nxt[i+1]][(s[i+1]-'a')^1],v);
	}	
	int ans=0; int sum=0;
	for(int i=n;i>=1;i--)
	{		
		if(sum==0) ans=add(ans,add(dp[i][0],dp[i][1]));
		sum+=(s[i]=='a'?1:2); sum%=3;
	}
	cout<<ans<<'\n';
}
