#include<iostream>
#define int long long
using namespace std;
const int N=1e5+2;
const int mod=1e9+7;
int dp[N],sum[N][3],last[3];
signed main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  int n,i,j,k,l=0;
  cin>>s;
  n=s.size();
  s=" "+s;
  dp[0]=1;
  sum[0][0]=1;
  last[1]=-1;
  last[2]=-1;
  bool cac=true;
  for(i=1;i<=n;i++){
    if(s[i]==s[i-1]){
      cac=false;
    }
    if(s[i]=='a'){
      l++;
    }
    else{
      l+=2;
    }
    if(l>=3){
      l-=3;
    }
    for(j=0;j<3;j++){
      sum[i][j]=sum[i-1][j];
      dp[i]+=sum[i][j];
        if(last[l]>-1){
          dp[i]-=sum[last[l]][j];
        }
    }
  	dp[i]-=sum[i][l];
    if(last[l]>-1){
      dp[i]+=sum[last[l]][l];
    }
    dp[i]=(dp[i]%mod+mod)%mod;
    last[l]=i;
    sum[i][l]+=dp[i];
    sum[i][l]%=mod;
    //cout<<dp[i]<<endl;
  }
  if(cac){
    cout<<1;
    return 0;
  }
  if(!l){
    sum[n][l]=(sum[n][l]-1+mod)%mod;
  }
  cout<<sum[n][l];
}