#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
int N;
char S[100005];
int Next[100005], P[100005], DP[100005];
const int MOD = 1000000007;
vector <int> V[3];
int ind[3];
void Read()
{
    cin.getline(S + 1, 100005);
    N = strlen(S + 1);
    //V[P[0]].push_back(0);
    for(int i = 1; i <= N; i++)
    {
        P[i] = P[i - 1] + S[i] - 'a' + 1;
        while(P[i] >= 3)
            P[i] -= 3;
        V[P[i]].push_back(i);
    }
}
inline void Add(int& x, int y)
{
    x += y;
    if(x >= MOD)
        x -= MOD;
}
void Solve()
{
    int next = 1;
    DP[1] = 1;
    int ans = 0;
    for(int i = 1; i <= N; i++)
    {
        if(next <= i)
        {
            while(next <= N && (S[next] != S[next - 1] || next <= i))
            {
                ind[P[next]]++;
                ++next;
            }
        }
        Add(DP[i + 1], DP[i]);
        for(int j = 0; j < 3; j++)
        {
            if(P[i - 1] == j || ((j - P[i - 1] + 3) % 3) == S[i] - 'a' + 1)
                continue;
            if(ind[j] == V[j].size())
                continue;
            Add(DP[V[j][ind[j]] + 1], DP[i]);
        }
        if(P[N] == P[i - 1] && i > 1)
            Add(ans, DP[i]);
    }
    Add(ans, DP[N + 1]);
    /*for(int i = N - 1; i > 1; i--)
    {
        if(S[i] == S[i + 1])
            break;
        if(P[N] == P[i - 1] && S[i - 1] != S[i])
            Add(ans, MOD - 1);
    }*/
    cout << ans << '\n';
}
int main()
{
    Read();
    bool ok = 0;
    for(int i = 2; i <= N; i++)
        if(S[i] == S[i - 1])
        {
            ok = 1;
            break;
        }
    if(ok == 0)
    {
        cout << "1\n";
        return 0;
    }
    Solve();
    return 0;
}
