#include <bits/stdc++.h>
const int maxn = int(1e5) + 7, mod = int(1e9) + 7;
namespace Solve {
	int next[maxn][3], f[maxn], sum[maxn], n, ans;
	char str[maxn];
	int main() {
		scanf("%s", str);
		n = int(strlen(str));
		bool flag = true;
		for (int i = 1; str[i]; i++) flag &= str[i] != str[i - 1];
		if (flag) return 0 * puts("1");
		for (int i = 0; i < n; i++) sum[i + 1] = (sum[i] + 1 + (str[i] == 'b')) % 3;
		next[n][0] = next[n][1] = next[n][2] = n + 1;
		for (int i = n - 1; ~i; i--) {
			for (int j = 0; j < 3; j++) {
				next[i][j] = next[i + 1][j];
			}
			next[i][sum[i + 1]] = i + 1;
		}
		f[0] = 1;
		for (int i = 0; i <= n; i++) {
			for (int j = 1; j <= 2; j++) {
				if (next[i][(sum[i] + j) % 3] <= n) {
					f[next[i][(sum[i] + j) % 3]] = (f[i] + f[next[i][(sum[i] + j) % 3]]) % mod;
				}
			}
			if (i > 0 && sum[i] == sum[n]) ans = (ans + f[i]) % mod;
		}
		printf("%d\n", ans);
		return 0;
	}
}
int main() {
#ifdef AC
	freopen("../in", "r", stdin);
#endif
	return Solve::main();
}

