#include <bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair <int, int>
#define iiii pair <int, pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i, x) for(int (i) = 0; (i) < (x); (i)++)
inline int getint() {
	int x = 0, p = 1; char c = getchar();	
	while (c <= 32) c = getchar();
	if (c == 45) p = -p, c = getchar();
	while (c > 32) x = x * 10 + c - 48, c = getchar();
	return x * p;
}
using namespace std;
//ruogu_alter
const int N = 1e5 + 5;
char s[N];
int n, pre[N], nxt[N][3], dp[N];
//
inline void add(int &x, int y) {
	x += y; if (x >= MOD) x -= MOD;
}
bool is1() {
	for (int i = 2; i <= n; i++) if (s[i] == s[i - 1]) return false;
	return true;
}
int main() {
	scanf("%s", s + 1); n = strlen(s + 1);
	if (is1()) return !printf("%d\n", 1);
	for (int i = 1; i <= n; i++) {
		pre[i] = (pre[i - 1] + s[i] - 'a' + 1) % 3;
	}
	rep(i, 3) nxt[n][i] = n + 1;
	for (int i = n - 1; i >= 0; i--) {
		rep(j, 3) nxt[i][j] = nxt[i + 1][j];
		nxt[i][pre[i + 1]] = i + 1;
	}
	dp[0] = 1;
	rep(i, n) {
		int x = pre[i];
		rep(j, 3) if(j) add(dp[nxt[i][(j + x) % 3]], dp[i]);
	}
	int res = 0;
	for (int i = 1; i <= n; i++) if (pre[i] == pre[n]) {
		add(res, dp[i]);
	}
	cout << res << endl;
	return 0;
}
