#include <bits/stdc++.h>

using namespace std;

const int Mod = 1e9 + 7, Nmax = 1e5 + 5;
void regl(int &x) { if(x>=Mod) x-=Mod; }

int n, i, j, ans, dp[Nmax], nxt[Nmax][3], s[Nmax];
char a[Nmax];

int main()
{
 ///   freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> (a+1);
    n = strlen(a+1);

    bool ok = 0;
    for(i=1; i<=n; ++i)
    {
        ok |= (i<n && a[i] == a[i+1]);
        a[i] -= 'a' - 1;
        s[i] = (s[i-1] + a[i]) % 3;
    }

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

    nxt[n+1][0] = nxt[n+1][1] = nxt[n+1][2] = n+1;
    for(i=n; i>=0; --i)
        memcpy(nxt[i], nxt[i+1], sizeof(nxt[i])), nxt[i][s[i]] = i;

    dp[0] = 1;
    for(i=0; i<=n; ++i)
    {
        dp[nxt[i][ (s[i]+1)%3 ]] += dp[i];
        regl(dp[nxt[i][ (s[i]+1)%3 ]]);

        dp[nxt[i][ (s[i]+2)%3 ]] += dp[i];
        regl(dp[nxt[i][ (s[i]+2)%3 ]]);

        if(s[i] == s[n] && i) ans += dp[i], regl(ans);
    }

    cout << ans << '\n';
    return 0;
}
