#include <bits/stdc++.h>

const int MAXN = 100010;
const int mod = 1000000007;
void reduce(int & x) { x += x >> 31 & mod; }
char buf[MAXN];
int dp[MAXN];
int d[3];
int main() {
	std::cin >> buf + 1; int len = strlen(buf + 1);
	bool flg = true;
	int pre = 0;
	dp[0] = d[0] = 1;
	for (int i = 1; i <= len; ++i) {
		buf[i] = buf[i] == 'a' ? 1 : 2;
		if (i > 1) flg &= buf[i] != buf[i - 1];
		pre = (buf[i] + pre) % 3;
		reduce(dp[i] = dp[i - 1] + d[(6 - (buf[i] ^ 3) + pre) % 3] - mod);
		if (!pre) reduce(dp[i] += 1 - mod);
		d[pre] = dp[i];
	}
	int ans = dp[len];
	if (!pre) reduce(ans -= 1);
	if (flg) ans = 1;
	std::cout << ans << std::endl;
	return 0;
}
