#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5, mod = 1e9 + 7;
char s[maxn + 10];
int a[maxn + 10], b[maxn + 10], tr[maxn + 10][3];
int to[maxn + 10], n, ans, f[maxn + 10];
int main() {
	scanf("%s", s + 1); n = strlen(s + 1);
	for (int i = 1; i <= n; ++i) {
		if (s[i] == 'a') a[i] = 1;
		else a[i] = 2;
		b[i] = (b[i - 1] + a[i]) % 3;
	}
	for (int i = 0; i < 3; ++i) tr[n + 1][i] = n + 1;
	for (int i = n; i >= 1; --i) {
		if (i == n) to[i] = n + 1;
		else if (a[i] == a[i + 1]) to[i] = i + 1;
		else to[i] = to[i + 1];
		for (int j = 0; j < 3; ++j) tr[i][j] = tr[i + 1][j];
		tr[i][b[i]] = i;
	}
	if (to[1] == n + 1) {
		printf("1"); return 0;
	}
	f[0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 1; j < 3; ++j)
			if (a[i + 1] == j) (f[i + 1] += f[i]) %= mod;
			else {
				int p = to[i + 1];
				if (p <= n) p = tr[p][(b[i] + j) % 3];
				if (p <= n) (f[p] += f[i]) %= mod;
			}
	}
	int sum = 0;
	for (int i = n; i >= 1; --i) {
		if (!sum) (ans += f[i]) %= mod;
		sum = (sum + a[i]) % 3;
	}
	printf("%d", ans);
}
