#include <bits/stdc++.h>
using namespace std;

const int N = 100005, P = 1000000007;
int n, sum[N], dp[N], fst[N];
vector<int> pos[3];
char s[N];

int main() {
	scanf("%s", s + 1), n = strlen(s + 1);
	bool flag = true;
	for (int i = 2; i <= n; ++i)
		flag &= s[i] != s[i - 1];
	if (flag) return puts("1"), 0;
	for (int i = 1; i <= n; ++i) {
		sum[i] = (sum[i - 1] + (s[i] == 'a' ? 1 : 2)) % 3;
		pos[sum[i]].push_back(i);
	}
	fst[n] = n + 1;
	for (int i = n - 1; i; --i)
		if (s[i] == s[i + 1]) fst[i] = i;
		else fst[i] = fst[i + 1];
	dp[0] = 1;
	for (int i = 0; i < n; ++i) {
		dp[i + 1] = (dp[i + 1] + dp[i]) % P;
		char x = 'a' + 'b' - s[i + 1];
		if (fst[i + 1] <= n) {
			const auto &v = pos[(sum[i] + (x == 'a' ? 1 : 2)) % 3];
			int t = lower_bound(v.begin(), v.end(), fst[i + 1]) - v.begin();
			if (t != v.size())
				dp[v[t]] = (dp[v[t]] + dp[i]) % P;
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		if (sum[i] == sum[n]) ans = (ans + dp[i]) % P;
	printf("%d\n", ans);
	return 0;
}
