#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9 + 7;
const int N = 1e5 + 10;

int n, last[3] = {0,-1,-1}, dp[N];
string s;

int main() {
    cin >> s;
    int n = s.size();
    s = ' ' + s;
    bool rep = 0;
    for (int i = 0; i < (int) s.size()-1; i++) rep |= s[i] == s[i+1];
    if (!rep) return cout << 1, 0;

    dp[0] = 1;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        int x = s[i]-'a'+1;
        sum += x;
        if (sum >= 3) sum -= 3;

        dp[i] = 0;
        for (int c = 1; c <= 2; c++) {
            int j = last[(sum+3-c)%3];
            if (j >= 0) {
                dp[i] += dp[j];
                if (dp[i] >= MOD) dp[i] -= MOD;
            }
        }
        if (sum == 0) {
            ++dp[i];
            if (dp[i] >= MOD) dp[i] -= MOD;
        }
        last[sum] = i;
    }
    cout << (dp[n] + MOD- (sum == 0)) % MOD << endl;
    return 0;
}
