#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 100005;
const int MOD = 1e9 + 7;;
 
template <typename T> inline void read(T &AKNOI) {
    T x = 0, flag = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') flag = -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    AKNOI = flag * x;
}
 
namespace ModCalculator {
	inline void Inc(int &x, int y) {
		x += y; if (x >= MOD) x -= MOD;
	}
	inline void Dec(int &x, int y) {
		x -= y; if (x < 0) x += MOD;
	}
	inline int Add(int x, int y) {
		Inc(x, y); return x;
	}
	inline int Sub(int x, int y) {
		Dec(x, y); return x;
	}
	inline int Mul(int x, int y) {
		return 1LL * x * y % MOD;
	}
}
using namespace ModCalculator;

char s[MAXN];
int n, sum[MAXN], nxt[MAXN][3];
int dp[MAXN], ans;

void init() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
}

void solve() {
	bool flag = 1;
	for (int i = 1; i < n; ++i) {
		if (s[i] == s[i + 1]) {
			flag = 0; break;
		}
	}
	if (flag) {
		printf("1\n");
		return;
	}
	for (int i = 1; i <= n; ++i) {
		sum[i] = (sum[i - 1] + (s[i] - 'a' + 1)) % 3;
	}
	nxt[n][0] = nxt[n][1] = nxt[n][2] = n + 1;
	for (int i = n; i >= 0; --i) {
		for (int j = 0; j < 3; ++j) {
			nxt[i][j] = nxt[i + 1][j];	
		}
		nxt[i][sum[i + 1]] = i + 1;
	}
	dp[0] = 1;
	for (int i = 0; i <= n; ++i) {
		if (i && sum[i] == sum[n]) {
			Inc(ans, dp[i]);
		}
		for (int j = 1; j < 3; ++j) {
			Inc(dp[nxt[i][(sum[i] + j) % 3]], dp[i]);
		}
	}
	printf("%d\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}
