#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	char a[N + 1];
	int b[N + 1];
	int na[N + 1];
	int nb[N + 1];
	long long dp[N + 1];
	f(i, N + 1)a[i] = 0;
	int n, k;
	int x, y, z;
	int r[3];
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%s", a);
	n = strlen(a);
	f(i, n){
		if (i % 2 == 0 && a[i] != a[0])v = false;
		if (i % 2 == 1 && a[i] == a[0])v = false;
	}
	if (v){
		printf("1\n");
		return 0;
	}
	if (a[0] == 'a')b[0] = 1;
	else b[0] = 2;
	f(i, n-1){
		if (a[i + 1] == 'a')b[i + 1] = (b[i] + 1) % 3;
		else b[i + 1] = (b[i] + 2) % 3;
	}
	r[0] = n;
	r[1] = n;
	r[2] = n;
	for (int i = n - 1; i >= 0; i--){
		na[i] = r[((b[i] + 1) % 3)];
		nb[i] = r[((b[i] + 2) % 3)];
		r[b[i]] = i;
	}
	ans = 0;
	f(i, N)dp[i] = 0;
	dp[r[1]]++;
	dp[r[2]]++;
	for(int i=0;i<n;i++){
		dp[na[i]] = (dp[na[i]] + dp[i]) % MOD;
		dp[nb[i]] = (dp[nb[i]] + dp[i]) % MOD;
		if (b[i] == b[n - 1])ans = (ans + dp[i]) % MOD;
	}

	printf("%lld\n", ans);


	return 0;
}