#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
inline int read()
{
	int x = 0 , f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{if(ch == '-')	f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 1e5 + 5 , mod = 1e9 + 7;
char s[N];
int ch[N][2] , f[N];
int main()
{
	scanf("%s",s + 1); int n = strlen(s + 1);
	int flag = 0 , sum = 0;
	for(int i = 2;i <= n;i ++) flag += (s[i] == s[i - 1]);
	if(!flag) return puts("1") , 0;
	f[n + 1] = 1;
	for(int i = 1;i <= 2;i ++) for(int j = 0;j < 2;j ++) ch[n + i][j] = n + 2;
	for(int i = n;i >= 1;i --)
	{
		sum = (sum + (s[i] == 'a' ? 1 : 2)) % 3;
		ch[i][0] = s[i] == 'a' ? i + 1 : s[i + 1] == 'b' ? i + 2 : ch[i + 2][0];
		ch[i][1] = s[i] == 'b' ? i + 1 : s[i + 1] == 'a' ? i + 2 : ch[i + 2][1];
		f[i] = (f[ch[i][0]] + f[ch[i][1]] + (sum == 0)) % mod;
	}
	printf("%d\n",(f[1] - (sum == 0) + mod) % mod);
	return 0;
}