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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const ll MOD = 1000000007;
const int MN = 100010;

int acc[MN];
ll dp[MN];
int nx[MN][3];

int main() {
	string s; cin >> s;
	int n = s.size();

	rep(i, n) {
		acc[i + 1] = (acc[i] + (s[i] != 'a') + 1) % 3;
	}

	rep(j, 3) nx[n][j] = n + 1;

	for (int i = n; i >= 1; --i) {
		rep(j, 3) {
			nx[i-1][j] = nx[i][j];
		}
		nx[i-1][acc[i]] = i;
	}

	bool alt = true;
	rep(i, n-1) {
		if (s[i] == s[i+1]) {
			alt = false;
		}
	}

	if (alt) {
		puts("1");
		return 0;
	}

	dp[0] = 1;

	rep(i, n) {
		for (int c = 1; c <= 2; ++c) {
			int m = (acc[i] + c) % 3;
			if (nx[i][m] <= n) {
				int p = nx[i][m];
				dp[p] = (dp[p] + dp[i]) % MOD;
			}
		}
	}

	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (acc[n] == acc[i]) {
			ans = (ans + dp[i]) % MOD;
		}
	}

	cout << ans << endl;

	return 0;
}