#include <bits/stdc++.h>

#define For(i, j, k) for (int i = j; i <= k; i++)
#define Forr(i, j, k) for (int i = j; i >= k; i--)

using namespace std;

const int N = 1e5 + 10;
const int Mod = 1e9 + 7;

char S[N];
int a[N], n;
int nxt[N][3], dp[N];

int main() {

	scanf("%s", S + 1);
	n = strlen(S + 1);
	For(i, 1, n) a[i] = S[i] - 'a' + 1;

	bool flag = true;
	For(i, 2, n) flag &= a[i] != a[i - 1];
	if (flag) { puts("1"); return 0; }
	For(i, 1, n) a[i] = (a[i - 1] + a[i]) % 3;

	For(j, 0, 2) nxt[n + 1][j] = n + 1;
	Forr(i, n, 1) For(j, 0, 2) nxt[i][j] = a[i] == j ? i : nxt[i + 1][j];

	int ans = 0;
	dp[0] = 1;
	For(i, 0, n) {
		For(j, 1, 2) {
			int p = nxt[i + 1][(a[i] + j) % 3];
			if (p <= n) dp[p] = (dp[p] + dp[i]) % Mod;
		}
		if (i > 0 && a[i] == a[n]) ans = (ans + dp[i]) % Mod;
	}

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

	return 0;
}