#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD=1e9+7;
int main()
{
    string s; cin>>s;
    int c[100010];
    int n=s.size();
    c[0]=0;
    for(int i=0; i<n; i++){
        if(s[i]=='a') c[i+1]=(c[i]+1)%3;
        else c[i+1]=(c[i]+2)%3;
    }
    int nx[100010];
    int p[3][100010];
    for(int j=0; j<3; j++) p[j][n]=n;
    int imx=-1;
    for(int i=n-1; i>=0; i--){
        for(int j=0; j<3; j++) p[j][i]=p[j][i+1];
        p[c[i]][i]=i;
        if(imx==-1 && i<n-1 && s[i]==s[i+1]) imx=i;
        if(s[i]=='a') nx[i]=p[(c[i]+2)%3][i];
        else nx[i]=p[(c[i]+1)%3][i];
    }
    int dp[100010]={};
    int ans=0;
    for(int i=0; i<n; i++){
        int x=(c[n]-c[i]+3)%3;
        if(x!=0) (ans+=dp[i])%=MOD;
        if(x!=0 && (i==n-1 || i<=imx)) (++ans)%=MOD;
        else if(i>0 && i-1==imx && s[i]==s[i-1]) (ans+=(n-i-1)/2)%=MOD;
        (dp[i+1]+=dp[i])%=MOD;
        (dp[nx[i]]+=dp[i]+1)%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}