#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const ll MOD = 1e9 + 7;

string s;
int sm[210000];
int nx[3];
int go[210000][3];
ll dp[210000];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	int fl = 0;
	cin >> s;
	for (int i = 0; i + 1 < s.size(); ++i) {
		if (s[i] == s[i + 1]) {
			fl = 1;
			break;
		}
	}
	if (!fl) {
		cout << 1 << "\n";
		return 0;
	}
	int n = s.size();
	sm[n] = 0;
	for (int i = n - 1; i >= 0; --i) {
		if (s[i] == 'a')
			sm[i] = sm[i + 1] + 1;
		else
			sm[i] = sm[i + 1] - 1;
		sm[i] = (sm[i] + 3) % 3;
	}
	for (int i = 0; i < 3; ++i)
		nx[i] = -1;
	int lst = n;
	for (int i = n - 1; i >= 0; --i) {
		if (lst > i + 1 && s[i + 1] == s[i]) {
			while (lst > i + 1) {
				nx[sm[lst]] = lst;
				--lst;
			}
		}
		if (s[i] == 'a') {
			go[i][0] = i + 1;
			go[i][1] = nx[(sm[i] + 1) % 3];
		}
		else {
			go[i][1] = i + 1;
			go[i][0] = nx[(sm[i] + 2) % 3];
		}
	}
	dp[0] = 1;
	for (int i = 0; i < s.size(); ++i) {
		for (int j = 0; j < 2; ++j)
			if (go[i][j] != -1)
				dp[go[i][j]] = (dp[go[i][j]] + dp[i]) % MOD;
	}
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (sm[i] == 0)
			ans = (ans + dp[i]) % MOD;
	}
	cout << ans << "\n";
	return 0;
}


