#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int Q=1<<17;
char s[Q];
int sm[Q];
int f[3];
const int MOD=1e9+7;
inline int add(int a,int b)
{a+=b;return a>=MOD?a-MOD:a;}
int main()
{
    scanf("%s",s+1);
    int n=strlen(s+1);
    int fl=0;
    for(int i=1;i<=n;i++){
        sm[i]=(sm[i-1]+(s[i]=='a'?1:2))%3;
        if(i>1&&s[i]==s[i-1])fl=1;
    }
    if(!fl)return printf("1")&0;
    for(int i=n;i>=0;--i){
        int now=sm[i]==sm[n];
        now=add(now,add(f[(sm[i]+1)%3],f[(sm[i]+2)%3]));
        f[sm[i]]=now;
    }
    printf("%d",add(f[1],f[2]));
    return 0;
}