#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;

const int MAXN = 200228;
int b[MAXN];
int a[MAXN];
int nx[MAXN][3];
const ll MOD = 1e9 + 7;
ll f[MAXN];

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    string s;
    cin >> s;

    int n = s.length();
    b[0] = 0;

    for (int i = 0; i < n; ++i) {
        a[i] = s[i] - 'a' + 1;
        b[i + 1] = (b[i] + a[i]) % 3;
    }

    bool alternate = true;
    for (int i = 1; i < s.length(); ++i) {
        alternate &= (s[i] != s[i - 1]);
    }

    if (alternate) {
        cout << 1 << "\n";
        return 0;
    }

    for (int i = 0; i < 3; ++i) {
        nx[n + 1][i] = n + 1;
    }

    for (int i = n; i >= 0; --i) {
        copy(nx[i + 1], nx[i + 1] + 3, nx[i]);
        nx[i][b[i]] = i;
    }

    ll ans = (b[0] == b[n]) ? (MOD - 1) : 0;
    f[0] = 1;

    for (int i = 0; i <= n; ++i) {
        if (b[i] == b[n]) {
            ans = (ans + f[i]) % MOD;
        }

        for (int j = 1; j <= 2; ++j) {
            int d = nx[i + 1][(b[i] + j) % 3];
            f[d] = (f[d] + f[i]) % MOD;
        }
    }

    cout << ans << "\n";
}

