#include <iostream>
#include <cstdio>
#include <cstring>
#define ll long long
using namespace std;
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 + 100,mod = 1e9 + 7;
int n,sum; char s[N];
int nex[N][2],f[N];
int main()
{
	scanf("%s",s + 1); n = strlen(s + 1);
	int flag = 1; for(int i = 1;i < n;i ++) if(s[i] == s[i + 1]) flag = 0;
	if(flag) {puts("1"); return 0;}
	sum = 0; f[n + 1] = 1; nex[n + 1][0] = nex[n + 1][1] = nex[n + 2][0] = nex[n + 2][1] = n + 2;
	for(int i = n;i >= 1;i --)  
	{
		sum = (sum + s[i] - 'a' + 1) % 3;
		nex[i][0] = s[i] == 'a' ? i + 1 : s[i + 1] == 'b' ? i + 2 : nex[i + 2][0];
		nex[i][1] = s[i] == 'b' ? i + 1 : s[i + 1] == 'a' ? i + 2 : nex[i + 2][1];
		f[i] = ((sum == 0) + f[nex[i][0]] + f[nex[i][1]] ) % mod;
 	}
 	cout << (f[1] - (sum == 0) + mod) % mod;
	return 0;
}