#include <bits/stdc++.h>

using namespace std;

const int mod = 1000000007;
char str[200050];
int dp[200050];
int nxt[200050][2];

int main()
{
	scanf("%s",str + 1);
	int n = strlen(str + 1);
	bool fg = 0;
	for(int i = 1;i < n; ++ i)
		fg |= str[i] == str[i + 1];
	if(!fg) return printf("1\n"),0;
	dp[n + 1] = 1;
	int sum = 0;
	for(int i = n;i >= 1; -- i)
	{
		sum = (sum + str[i] - 'a' + 1) % 3;
		nxt[i][0] = (str[i] == 'a') ? i + 1 : (str[i + 1] == 'b' ? i + 2 : nxt[i + 2][0]);
		nxt[i][1] = (str[i] == 'b') ? i + 1 : (str[i + 1] == 'a' ? i + 2 : nxt[i + 2][1]);
		dp[i] = (dp[nxt[i][0]] + dp[nxt[i][1]] + (sum == 0)) % mod;
	}
	printf("%d\n",dp[1] - (sum == 0));
}