#include <cstdio>
#include <cstring>

const int N = 100005, P = 1e9+7;
char s[N]; int sum[N], f[N], pre[3], n, flag;

int main() {
	scanf("%s", &s); n = strlen(s);
	for (int i = 1; i < n; ++i) //判断是否可以操作
		if (s[i] == s[i-1]) { flag = 1; break; }
	if (!flag) { puts("1"); return 0; }
	for (int i = 0; i < n; ++i) sum[i+1] = s[i] - 'a' + 1;
	for (int i = 2; i <= n; ++i) sum[i] = (sum[i] + sum[i-1]) % 3;
	f[n] = 1;
	for (int i = 0; i <= 2; ++i) pre[i] = (i == sum[n] ? n : n + 1);
	for (int i = n - 1; i; --i) {
		f[i] = (sum[i] == sum[n]); //后面的p值是否为0
		for (int j = 1; j <= 2; ++j)
			f[i] = (f[i] + f[pre[(sum[i]+j)%3]]) % P; //后面加一段A或B
		pre[sum[i]] = i; //记录该p值上一次出现的位置
	}
	printf("%d\n", (f[pre[1]] + f[pre[2]]) % P);
	return 0;
}