#include <bits/stdc++.h>
const int maxn = int(1e5) + 7, mod = int(1e9) + 7;
int next[maxn][3], f[maxn] = {1}, sum[maxn], ans;
char str[maxn];
int main() {
    scanf("%s", str);
    int 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;
    for (int i = 0; i < 3; i++) next[n][i] = n + 1;
    for (int i = n - 1; ~i; i--) for (int j = 0; j < 3; j++) next[i][j] = j == sum[i + 1] ? i + 1 : next[i + 1][j];
    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;
}

