#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<typename T> void chkmax(T &a, const T &b) { a = a > b ? a : b; }
template<typename T> void chkmin(T &a, const T &b) { a = a < b ? a : b; }

const int MAXN = 100005, MOD = 1e9 + 7;
void add(int &x, int y) { x += y - MOD, x += x >> 31 & MOD; }
int f[MAXN], tran[MAXN][3], suf[3], can[MAXN], n;
char str[MAXN];

int main() {
	scanf("%s", str + 1);
	n = strlen(str + 1);
	for (int i = 1; i <= n; i++)
		str[i] = str[i] - 'a' + 1;
	memset(tran[n + 1], -1, sizeof(tran[n + 1]));
	memset(suf, -1, sizeof(suf));
	for (int i = n; i > 0; i--) {
		int c = str[i], tmp[3] = { suf[(3 - c) % 3], suf[(4 - c) % 3], suf[(5 - c) % 3] };
		tmp[c] = i;
		if (str[i] == str[i + 1]) {
			tran[i][c] = suf[0];
			tran[i][c * 2 % 3] = i + 1;
			tran[i][0] = tmp[0];
		} else {
			tran[i][0] = tran[i + 1][(3 - c) % 3];
			tran[i][1] = tran[i + 1][(4 - c) % 3];
			tran[i][2] = tran[i + 1][(5 - c) % 3];
		}
		memcpy(suf, tmp, sizeof(suf));
		can[i] = (can[i + 1] + c) % 3;
	}
	if (tran[1][can[1]] < 0) return puts("1"), 0;
	f[0] = 1;
	int res = 0;
	for (int i = 0; i < n; i++) if (f[i]) {
		tran[i + 1][str[i + 1]] = i + 1;
		if (~tran[i + 1][1]) add(f[tran[i + 1][1]], f[i]);
		if (~tran[i + 1][2]) add(f[tran[i + 1][2]], f[i]);
		if (!can[i + 2]) add(res, f[i + 1]);
	}
	printf("%d\n", res % MOD);
	return 0;
}