#include<iostream>
#include<cstring>
#define DIM 100005
#define mod 1000000007
using namespace std;
int n, i, j, x, sol, ok;
char s[DIM];
int sum[DIM], nxt[DIM][3], d[DIM];
int main(){
    cin>> s + 1;
    n = strlen(s + 1);
    nxt[n][0] = nxt[n][1] = nxt[n][2] = -1;
    for(i = 1; i <= n; i++){
        sum[i] = (sum[i - 1] + s[i] - 'a' + 1) % 3;
        if(s[i] == s[i - 1]){
            ok = 1;
        }
    }
    for(i = n - 1; i >= 0; i--){
        nxt[i][0] = nxt[i + 1][0];
        nxt[i][1] = nxt[i + 1][1];
        nxt[i][2] = nxt[i + 1][2];
        nxt[i][ sum[i + 1] ] = i + 1;
    }
    if(ok == 0){
        cout<< 1;
        return 0;
    }
    d[0] = 1;
    for(i = 0; i <= n; i++){
        for(j = 1; j <= 2; j++){
            x = (sum[i] + j) % 3;
            if(nxt[i][x] != -1){
                d[ nxt[i][x] ] = (d[i] + d[ nxt[i][x] ]) % mod;
            }
        }
        if(sum[i] == sum[n] && i != 0){
            sol = (sol + d[i]) % mod;
        }
    }
    cout<< sol;
}
