#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
auto rd=read<int>;
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
const u32 P=1e9+7;
u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
u32 sum(u32 a, u32 b) {return inc(a, b);}
u32 dif(u32 a, u32 b) {return dec(a, b);}

const int N=1e5+1;
int n, p[N];
u32 f[N];
char s[N];
int main() {
	u32 ans=0;
	int pos[3]={};
	assert(scanf("%s", s)==1);
	n=strlen(s);
	for(int i=0; i<n; ++i) s[i]=(s[i]=='a')?1:2;
	bool diff=true;
	for(int i=1; i<n; ++i) if(s[i]==s[i-1]) diff=false;
	if(diff) {
		puts("1");
		return 0;
	}
	for(int i=0; i<n; ++i) p[i+1]=(p[i]+s[i])%3;
	f[0]=1;
	for(int i=0, j=0; i<n; ++i) {
		int pinkrabbit=(p[i]-s[i]+3)%3, &k=pos[pinkrabbit];
		inc(f[i+1], f[i]);
		if(cmax(j, i+1)) while(j<n&&s[j-1]!=s[j]) ++j;
		if(cmax(k, j+1)) while(k<=n&&p[k]!=pinkrabbit) ++k;
		if(k<=n) inc(f[k], f[i]);
		if(p[i]!=p[n]) inc(ans, f[i]);
	}
	printf("%u\n", ans);
	return 0;
}
