#include <bits/stdc++.h>
#define MOD 1000000007
#define last last2

using namespace std;

char str[100005];
int f[100005],last[100005][3];

int main() {
  memset(last,255,sizeof(last));
  scanf("%s",str+1);
  int n=strlen(str+1);
  int nr=0;
  while (nr<n&&str[nr+1]!=str[nr]) nr++;
  int l=0,s=0;
  last[0][0]=0;
  for(int i=1;i<=n;i++) {
  	s=(s+str[i]-'a'+1)%3;
  	memcpy(last[i],last[i-1],sizeof(last[i]));
  	last[i][s]=i;
  	if (str[i]==str[i-1]) l=i-2;
  	int u=last[l][(s+2)%3],v=last[l][(s+1)%3];
  	if (str[i]=='a') u=i-1; else v=i-1;
  	if (u!=-1) {
	  f[i]=(f[i]+f[u])%MOD;
	  if (u&&nr>=u&&nr<i) f[i]=(f[i]+((u-1)>>1))%MOD;
    }
    if (v!=-1) {
	  f[i]=(f[i]+f[v])%MOD;
	  if (v&&nr>=v&&nr<i) f[i]=(f[i]+((v-1)>>1))%MOD;
	}
  	if (s&&(i==1||nr<i)) f[i]=(f[i]+1)%MOD;
  }
  printf("%d\n",f[n]);
  return 0;
}