#include<cstdio> 
#include<cstring> 
const int maxn = 100007; 
char t[maxn]; 
int n,s[maxn]; 
int f[maxn]; 
const int mod = 1e9 + 7; 
int main() { 
	scanf("%s",t + 1); 
	n = strlen(t + 1); 
	bool flag = 0; 
	for(int i = 2;i <= n;++ i) if(t[i] == t[i - 1])flag = 1; 
	if(!flag) return !printf("1"); 
	int now = 0,pre[3] = {0,-1,-1}; f[0] = 1; 
	for(int i = 1;i <= n;++ i) { 
		now = (now + 2 - (t[i] == 'a')) % 3; 
		if(!now && i < n) f[i] = 1; ++ now,now %= 3; 
		if(pre[now] != - 1) (f[i] += f[pre[now]]) %= mod;  ++ now,now %= 3; 
		if(pre[now] != -1) (f[i] += f[pre[now]]) %= mod; ++ now,now %= 3; 
		pre[now] = i; 
	} 
	printf("%d",f[n]); 
} 