#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
const int mod = 1e9 + 7;

int n;
string s;
int f[N], sum[N];
int nxt[N][3], eq[N];

void add(int &x,int y) {
	x += y; if (x >= mod) x -= mod;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> s; n = s.size(); s = '~' + s;
	for (int i = 1; i <= n; ++i) {
		sum[i] = (sum[i - 1] + (s[i] == 'a' ? 1 : 2)) % 3;
	}
	for (int i = 0; i < 3; ++i) nxt[n + 1][i] = n + 1;
	for (int i = n; i >= 1; --i) {
		for (int j = 0; j < 3; ++j) {
			nxt[i][j] = nxt[i + 1][j];
		}
		nxt[i][sum[i]] = i;
	} 
	eq[n] = n;
	for (int i = n - 1; i >= 1; --i) {
		if (s[i] == s[i + 1]) eq[i] = i;
		else eq[i] = eq[i + 1];
	}
	if (eq[1] == n) return cout << 1 << '\n',0;
	f[0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int t = 1; t <= 2; ++t) {
			int want = (sum[i] + t) % 3;
			if (sum[i + 1] == want) add(f[i + 1], f[i]);
			else {
				int pos = nxt[eq[i] + 1][want];
				if (pos <= n) add(f[pos], f[i]);
			}
		}
	}
	int res = 0;
	for (int i = 1; i <= n; ++i) if (sum[i] == sum[n]) add(res, f[i]);
	cout << res << '\n';
}
