#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
const int N = 1e5 + 5, mod = 1e9 + 7;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
template <class T> T Max(T a, T b) { return a > b ? a : b; }
template <class T> T Min(T a, T b) { return a < b ? a : b; }
char s[N];
int n, sum, a[N], f[N], last[5];
signed 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) return puts("1"), 0;
	for(int i = 1; i <= n; ++ i) a[i] = (a[i - 1] + (s[i] == 'a' ? 1 : 2)) % 3;
	for(int i = 1; i <= n; ++ i) f[i] = (f[last[0]] + f[last[1]] + f[last[2]] + (a[i] >= 1) - f[last[a[i]]] + mod) % mod, last[a[i]] = i;
	printf("%d\n", f[n]);
	return 0;
}