#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int p = 1000000007;
#define vel vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	string s; cin >> s;
	int n = s.size();
	vector<vel> lis(3);
	vel sum(n + 1);
	bool fl = true;
	rep(i, n) {
		lis[sum[i]].push_back(i);
		sum[i + 1] = sum[i] + (s[i] - 'a') + 1; sum[i + 1] %= 3;
		if (i % 2 == 0 xor s[i] == s[0]) { fl = false; }
	}
	if (fl) { cout << 1 << endl; return 0; }
	vel dp(n);
	dp[0] = 1;
	int ans = 0;
	rep(i, n) {
		if (sum[i] != sum[n]) { ans += dp[i]; ans %= p; }
		int pla = (sum[i] + 1) % 3;
		auto itr = lower_bound(lis[pla].begin(), lis[pla].end(), i);
		if (itr != lis[pla].end()) { dp[*itr] += dp[i]; dp[*itr] %= p; }
		pla++; pla %= 3;
		itr = lower_bound(lis[pla].begin(), lis[pla].end(), i);
		if (itr != lis[pla].end()) { dp[*itr] += dp[i]; dp[*itr] %= p; }
	}
	cout << ans % p << endl;
}
