#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define ALL(x) begin(x), end(x)
using namespace std;

template <int32_t MOD>
struct mint {
    int64_t value;
    mint() = default;
    mint(int64_t value_) : value(value_) {}
    inline mint<MOD> operator + (mint<MOD> other) const { int64_t c = this->value + other.value; return mint<MOD>(c >= MOD ? c - MOD : c); }
    inline mint<MOD> operator - (mint<MOD> other) const { int64_t c = this->value - other.value; return mint<MOD>(c <    0 ? c + MOD : c); }
    inline mint<MOD> operator * (mint<MOD> other) const { int64_t c = this->value * int64_t(other.value) % MOD; return mint<MOD>(c < 0 ? c + MOD : c); }
    inline mint<MOD> & operator += (mint<MOD> other) { this->value += other.value; if (this->value >= MOD) this->value -= MOD; return *this; }
    inline mint<MOD> & operator -= (mint<MOD> other) { this->value -= other.value; if (this->value <    0) this->value += MOD; return *this; }
    inline mint<MOD> & operator *= (mint<MOD> other) { this->value = this->value * int64_t(other.value) % MOD; if (this->value < 0) this->value += MOD; return *this; }
    inline mint<MOD> operator - () const { return mint<MOD>(this->value ? MOD - this->value : 0); }
    inline bool operator == (mint<MOD> other) const { return value == other.value; }
};

constexpr int MOD = 1e9 + 7;
mint<MOD> solve(string const & s) {
    int n = s.length();

    // it becomes a corner case when no operation is available
    bool is_trivial = true;
    REP (i, n - 1) {
        if (s[i] == s[i + 1]) {
            is_trivial = false;
            break;
        }
    }
    if (is_trivial) {
        return 1;
    }

    // prepare invariants with modulo 3
    vector<mint<3> > invariant(n + 1);
    REP (i, n) {
        invariant[i + 1] = invariant[i] + (s[i] - 'a' + 1);
    }

    // construct the table
    vector<array<int, 2> > next(n, { INT_MAX, INT_MAX });
    array<array<array<vector<int>, 2>, 3>, 2> unused;
    REP (l, n) {
        // [*, l + 1)
        if (l >= 1 and s[l - 1] == s[l]) {
            REP (c, 2) {
                REP (d, 3) {
                    copy(ALL(unused[c][d][false]), back_inserter(unused[c][d][true]));
                    unused[c][d][false].clear();
                }
            }
        }
        REP (c, 2) {
            int d = (invariant[l + 1] - (c + 1)).value;
            for (int l1 : unused[c][d][true]) {
                next[l1][c] = l + 1;
            }
            unused[c][d][true].clear();
        }

        // [l, *)
        bool c = s[l] - 'a';
        next[l][c] = l + 1;
        unused[not c][invariant[l].value][false].push_back(l);
    }

    // run dp
    vector<mint<MOD> > dp(n + 1);
    dp[0] = 1;
    REP (l, n) {
        REP (c, 2) {
            if (next[l][c] != INT_MAX) {
                dp[next[l][c]] += dp[l];
            }
        }
    }

    // count the answer
    mint<MOD> acc = 0;
    REP3 (r, 1, n + 1) {
        if (invariant[n] - invariant[r] == 0) {
            acc += dp[r];
        }
    }
    return acc;
}

int main() {
    string s; cin >> s;
    cout << solve(s).value << endl;
    return 0;
}


Measured memory_bytes: 3456