#include <cstring>
#include <cstdio>
constexpr int MOD = 1e9 + 7;
char str[100005];
int nxt[100005][3], dp[100005], sum[100005];
int main()
{
	// freopen("AGC027-E.in", "r", stdin);
	scanf("%s", str);
	int n = strlen(str), ans = 0;
	bool flg = true;
	for (int i = 1; i < n; i++)
		flg &= str[i] != str[i - 1];
	if (flg)
	{
		puts("1");
		return 0;
	}
	for (int i = 0; i < n; i++)
		sum[i] = ((i ? sum[i - 1] : 0) + (str[i] - 'a' + 1)) % 3;
	nxt[n][0] = nxt[n][1] = nxt[n][2] = n;
	for (int i = n - 1; i >= 0; i--)
	{
		memcpy(nxt[i], nxt[i + 1], sizeof(nxt[i + 1]));
		nxt[i][sum[i]] = i;
	}
	dp[0] = 1;
	for (int i = 0; i < n; i++)
	{
		int x = i ? sum[i - 1] : 0;
		for (int j = 0; j < 3; j++)
		{
			if (j == x)
				continue;
			int y = nxt[i][j];
			if (y < n)
				(dp[y + 1] += dp[i]) %= MOD;
		}
		if (sum[i] == sum[n - 1])
			(ans += dp[i + 1]) %= MOD;
	}
	printf("%d\n", ans);
	return 0;
}
