#include<bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5, mod = 1e9 + 7;
int n, dp[N], r[N], prefSum[N], lst[N][3], Lst[3], ans;
string s;

void add (int &_a, int _b) {
    _a += _b;
    if (_a >= mod) _a -= mod;
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> s; n = s.size(); s = '!' + s;

    bool diff = 1;
    for (int i = 1; i < n; ++i) if (s[i] == s[i + 1]) diff = 0;
    if (diff) return cout << 1, 0;

    int R = n + 1;
    for (int i = n; i >= 0; --i) {
        r[i] = R;
        if (s[i] == s[i + 1]) R = i + 1;
    }

    for (int i = 1; i <= n; ++i) prefSum[i] = (prefSum[i - 1] + (s[i] == 'a' ? 1 : 2) ) % 3;

    Lst[0] = Lst[1] = Lst[2] = n + 1;
    for (int i = n; i > 0; --i) {
        Lst[ prefSum[i] ] = i;
        for (int j = 0; j < 3; ++j) lst[i][j] = Lst[j];
    }

    dp[0] = 1;
    for (int i = 0; i <= n; ++i) {
        add(dp[i + 1], dp[i]);
        if (r[i] <= n) {
            for (int j = 0; j < 3; ++j) {
                int tmp = (prefSum[ lst[ r[i] ][j] ] - prefSum[i] + 3) % 3;
                if (s[i + 1] == 'a' && tmp == 2) add(dp[ lst[ r[i] ][j] ], dp[i]);
                if (s[i + 1] == 'b' && tmp == 1) add(dp[ lst[ r[i] ][j] ], dp[i]);
            }
        }
    }

    for (int i = n; i > 0; --i) if (prefSum[i] == prefSum[n]) add(ans, dp[i]);

    cout << ans;

    return 0;
}
