#include <cstdio>
#include <cstring>

using namespace std;

#define MOD 1000000007

int n;

char s[100005];
int psum[100005];
int nxt[100005][2];
int f[100005];

int main()
{
    scanf("%s", s + 1);
    n = strlen(s + 1);
    bool hassame = false;
    for (int i = 1; i < n; i++) {
        if (s[i] == s[i+1]) hassame = true;
    }
    if (!hassame) {
        printf("1"); return 0;
    }
    for (int i = 1; i <= n; i++) {
        psum[i] = psum[i-1] + (s[i] == 'a' ? 1 : 2);
        psum[i] %= 3;
    }
    int tmp[3]; /* next acceptable with this psum */
    tmp[0] = tmp[1] = tmp[2] = n + 1;
    int tmp2[3]; /* next with this psum */
    tmp2[0] = tmp2[1] = tmp2[2] = n + 1;
    for (int i = n; i >= 1; i--) {
        if (i != n && s[i] == s[i+1]) {
            for (int j = 0; j < 3; j++) tmp[j] = tmp2[j];
        }
        nxt[i][0] = tmp[(psum[i-1] + 1) % 3];
        nxt[i][1] = tmp[(psum[i-1] + 2) % 3];
        if (s[i] == 'a') {
            nxt[i][0] = i;
        } else {
            nxt[i][1] = i;
        }
        tmp2[psum[i]] = i;
    }
    f[0] = 1;
    for (int i = 0; i < n; i++) {
        if (nxt[i+1][0] <= n) {
            f[nxt[i+1][0]] += f[i];
            if (f[nxt[i+1][0]] >= MOD) f[nxt[i+1][0]] -= MOD;
        }
        if (nxt[i+1][1] <= n) {
            f[nxt[i+1][1]] += f[i];
            if (f[nxt[i+1][1]] >= MOD) f[nxt[i+1][1]] -= MOD;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if ((psum[n] - psum[i] + 3) % 3 == 0) {
            ans += f[i];
            if (ans >= MOD) ans -= MOD;
        }
    }
    printf("%d", ans);
    return 0;
}
