#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
string str;
ll dp[100005];
int rui[100005];
int n;
vector<int>adj;
vector<int>pos[3];
int las = -1;
ll rec(int beg){
	if(beg == n) return 1;
	if(dp[beg] >= 0) return dp[beg];
	
	char ch = str[beg];
	ll add = rec(beg+1);
	if(beg+1 != n && rui[n-1] == rui[beg] && las >= beg) add = (add+1)%mod;
	if(las == beg){
		int zan = n-1-beg;
		if(zan > 0 && zan%2 == 0) zan -= 2;
		add = (add+1LL*(zan/2))%mod;
	}
	int f = POSL(adj,beg);
	if(f != adj.size()){
		int rg = adj[f]+1;
		int need = (str[beg] == 'a'?1:2);
		int target = (rui[beg]+need)%3;
		int h = POSL(pos[target],rg);
		if(h != pos[target].size()){
			int en = pos[target][h];
			add = (add+rec(en+1))%mod;
			if(en+1 != n && rui[n-1] == rui[en]) add = (add+1)%mod;
			if(las <= en){
				int zan = n-1-en;
				if(zan > 0 && zan%2 == 0) zan -= 2;
				add = (add+1LL*(zan/2))%mod;
			}
		}
	}
	return dp[beg] = add;
}
int main(){
	cin>>str;
	n = str.size();
	for(int i=1;i<n;i++){
		if(str[i-1] == str[i]){
			adj.pb(i-1);
			las = i-1;
		}
	}
	for(int i=0;i<n;i++){
		rui[i] = (str[i]=='a'?1:2);
		if(i) rui[i] = (rui[i]+rui[i-1])%3;
		pos[rui[i]].pb(i);
	}
	memset(dp,-1,sizeof(dp));
	ll ans = rec(0);
	ans = (ans%mod+mod)%mod;
	cout<<ans<<endl;
}