#include <iostream>
#include <cstring>
#include <cstdio>
#define mod 1000000007
using namespace std;
char s[1000006];
int f[1000006], last[3];
int main(){
	scanf("%s", s + 1);
	int n = strlen(s + 1), c = 0;
	bool flag = false;
	for (int i = 2; i <= n; ++ i)
		if (s[i] == s[i - 1]){
			flag = true;
			break;
		}
	if (! flag){
		cout << 1 << endl;
		return 0;
	}
	last[1] = n + 1, last[2] = n + 1;
	f[0] = 1;
	for (int i = 1; i <= n; ++ i){
		(c += s[i] == 'a' ? 1 : 2) %= 3;
		if (c == 0 && i < n)
			f[i] = 1;
		(f[i] += f[last[(c + 1) % 3]]) %= mod;
		(f[i] += f[last[(c + 2) % 3]]) %= mod;
		last[c] = i;
	}
	cout << f[n] << endl;
}
