#include<bits/stdc++.h>
#define maxn 100010
#define mod 1000000007
using namespace std;
char s[maxn];
int pre[maxn], nxt[maxn][3], able[maxn][3], f[maxn];
int main()
{
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	for (int i = 1; i <= n; i++)
	{
		pre[i] = pre[i - 1];
		if (s[i] == 'a') pre[i] = (pre[i] + 1) % 3;
		else pre[i] = (pre[i] + 2) % 3;
	}
	int flag = 0;
	for (int i = 1; i <= n - 1; i++)
		if (s[i] == s[i + 1]) flag = 1;
	if (flag == 0) {puts("1"); return 0;}
	for (int i = 0; i <= 2; i++)
		nxt[n + 1][i] = able[n + 1][i] = n + 1;
	for (int i = n; i >= 0; i--)
	{
		for (int j = 0; j <= 2; j++)
		{
			nxt[i][j] = nxt[i + 1][j];
			able[i][j] = able[i + 1][j];
		}
		if (i)
		{
			nxt[i][pre[i]] = i;
			able[i][pre[i]] = i;
		}
		for (int j = 0; j <= 2; j++)
			if (i != n && i != 0 && s[i] == s[i + 1]) able[i][j] = min(able[i][j], nxt[i + 1][j]);
	}
	f[0] = 1;
	for (int i = 0; i <= n - 1; i++)
		for (int j = 1; j <= 2; j++)
		{
			int tmp = able[i][(j + pre[i]) % 3];
			f[tmp] = (f[tmp] + f[i]) % mod;
		}
	int res = 0;
	for (int i = 1; i <= n; i++)
		if (pre[n] == pre[i]) res = (res + f[i]) % mod;
	printf("%d\n", res);
	return 0;
}