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

typedef long long ll;
const int maxn = 1e5 + 5, mod = 1e9 + 7;

inline int gi()
{
	char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	int sum = 0;
	while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
	return sum;
}

inline void inc(int &a, int b) {a += b; if (a >= mod) a -= mod;}

char s[maxn];
int n, sum, flg, nxt[2][maxn], f[maxn];

int main()
{
	scanf("%s", s + 1); n = strlen(s + 1);
	flg = 0;
	for (int i = 1; i < n; ++i) flg += s[i] == s[i + 1];
	if (!flg) return puts("1"), 0;
	f[n + 1] = 1; nxt[0][n + 1] = nxt[1][n + 1] = nxt[0][n + 2] = nxt[1][n + 2] = n + 2;
	for (int i = n; i; --i) {
		(sum += s[i] - 'a' + 1) %= 3;
		nxt[0][i] = s[i] == 'a' ? i + 1 : nxt[1][i + 1];
		nxt[1][i] = s[i] == 'b' ? i + 1 : nxt[0][i + 1];
		f[i] = sum == 0;
		inc(f[i], f[nxt[0][i]]);
		inc(f[i], f[nxt[1][i]]);
	}
	printf("%d\n", f[1] - (sum == 0));
	
	return 0;
}
