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

const int maxn = 1e5, mod = 1e9 + 7;
int n, a[maxn + 3], pos[maxn + 3][3], dp[maxn + 3], lst[maxn + 3];
char s[maxn + 3];

void upd(int &x, int y) {
	x += y, x < mod ? 0 : x -= mod;
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	bool flag = true;
	for (int i = 1; i < n; i++) {
		flag &= s[i] != s[i + 1];
	}
	if (flag) {
		puts("1");
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		a[i] = s[i] == 'a' ? 1 : 2;
		a[i] = (a[i] + a[i - 1]) % 3;
	}
	for (int i = n; i; i--) {
		lst[a[i]] = i;
		for (int j = 1; j <= 2; j++) {
			pos[i][j] = lst[(a[i - 1] + j) % 3];
		}
	}
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= 2; j++) {
			if (pos[i + 1][j]) {
				upd(dp[pos[i + 1][j]], dp[i]);
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		if ((a[n] - a[i] + 3) % 3 == 0) {
			upd(ans, dp[i]);
		}
	}
	printf("%d\n", ans);
	return 0;
}