#include <cstdio>

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

char s[N];
int a[N], n, f[N], nxt[3];

int main() {
	scanf("%s", s);
	for (; s[n]; ++n) a[n+1] = (a[n] + s[n] - 'a' + 1) % 3;
	int flag = 0;
	for (int i = 1; i < n; ++i) {
		if (s[i] == s[i-1]) flag = 1;
		// printf("%d\n", a[i]);
	}
	if (!flag) {
		puts("1");
		return 0;
	}
	f[n] = 1;
	for (int i = 0; i < 3; ++i) nxt[i] = i == a[n] ? n : n + 1;
	for (int i = n-1; i >= 0; --i) {
		f[i] = i && a[i] == a[n];
		for (int c = 1; c <= 2; ++c) {
			(f[i] += f[nxt[(a[i]+c)%3]]) %= MOD;
		}
		nxt[a[i]] = i;
 	}
 	printf("%d\n", f[0]);
	return 0;
}