// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
char in[110000];
long long dp[110000];
vector<int>v[3];
int sum[110000];
int main(){
	scanf("%s",in);
	int n=strlen(in);
	bool ok=true;
	for(int i=1;i<n;i++){
		if(in[i]==in[i-1]){
			ok=false;
			sum[i+1]++;
		}
	}
	for(int i=0;i<=n;i++){
		sum[i+1]+=sum[i];
		// printf("%d %d\n",i,sum[i]);
	}
	if(ok){
		printf("1\n");return 0;
	}
	int t=0;
	for(int i=0;i<n;i++){
		if(in[i]=='a')t++;
		else t+=2;
		v[t%3].push_back(i+1);
	}

	dp[0]=1;
	int now=0;
	for(int i=0;i<n;i++){
		if(dp[i]==0)continue;
		// printf("%d: %lld\n",i,dp[i]);
		int left,right;
		left=-1;
		right=v[(now+1)%3].size();
		while(left+1<right){
			int M=(left+right)/2;
			int to=v[(now+1)%3][M];
			bool dame=false;
			if(to<=i)dame=true;
			if(to-i>1&&sum[to]-sum[i+1]==0)dame=true;
			if(dame){
				left=M;
			}else right=M;
		}
		if(in[i]=='a'){
			dp[i+1]=(dp[i+1]+dp[i])%mod;
		}else if(right<v[(now+1)%3].size()){
			dp[v[(now+1)%3][right]]=(dp[v[(now+1)%3][right]]+dp[i])%mod;
		}
		left=-1;
		right=v[(now+2)%3].size();
		while(left+1<right){
			int M=(left+right)/2;
			int to=v[(now+2)%3][M];
			bool dame=false;
			if(to<=i)dame=true;
			if(to-i>1&&sum[to]-sum[i+1]==0)dame=true;
			if(dame){
				left=M;
			}else right=M;
		}
		if(in[i]=='b'){
			dp[i+1]=(dp[i+1]+dp[i])%mod;
		}else if(right<v[(now+2)%3].size()){
			dp[v[(now+2)%3][right]]=(dp[v[(now+2)%3][right]]+dp[i])%mod;
		}
		// printf("%d\n",v[(now+2)%3][right]);
		if(in[i]=='a')now++;
		else now+=2;
	}
	int s=0;
	long long ret=0;
	for(int i=1;i<=n;i++){
		if(in[i-1]=='a')s++;
		else s+=2;
		if(t%3==s%3){
			ret=(ret+dp[i])%mod;
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 2168