#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;

int n, f[101000], las[3];
char s[101000];

int main(){
    cin>>s+1; n=strlen(s+1);
    for (int i=2;;++i){
        if (i>n) return puts("1"), 0;
        if (s[i]==s[i-1]) break;
    }
    las[0]=n+1; las[1]=las[2]=n+2;
    int sum=0; f[n+1]=1;
    for (int i=n;i>=1;--i){
        sum=(sum+1+(s[i]=='b'))%3;
        f[i]=f[i+1];
        int aim=(sum-1-(s[i]=='a')+3)%3;
        f[i]=(f[i]+f[las[aim]])%mod;
        las[sum]=i;
        if (!sum&&i>1) f[i]=(f[i]+1)%mod;
    }
    cout<<f[1]<<endl;
}