#include <cstdio>
#include <cstring>
using namespace std;

typedef long long LL;

const int N = 1e5 + 10;
const LL mod = 1e9 + 7;

int n;
char s[N];

LL f[N];

int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	bool flag = 0;
	for (int i = 1; i <= n; ++ i)
		if (s[i] == s[i - 1]) flag = 1;
	if (!flag) return printf("1\n"), 0;
	f[0] = 1;
	for (int i = 1, sum = 0, pre[3] = { 0, - 1, - 1 }; i <= n; ++ i)
	{
		(sum += 1 + (s[i] != 'a')) %= 3;
		if (!sum && i < n) f[i] = 1;
		(++ sum) %= 3;
		if (pre[sum] != - 1) (f[i] += f[pre[sum]]) %= mod;
		(++ sum) %= 3;
		if (pre[sum] != - 1) (f[i] += f[pre[sum]]) %= mod;
		(++ sum) %= 3;
		pre[sum] = i;
	}
	printf("%lld\n", f[n]);
}