#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

string s;
llint sum[100005], pos[100005];
set<llint> S[3], T;
llint dp[100005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	llint n = s.size();
	s = "#" + s;
	
	S[0].insert(0);
	for(int i = 1; i <= n; i++){
		sum[i] = (sum[i-1] + s[i]-'a'+1) % 3;
		S[sum[i]].insert(i);
	}
	for(int i = 2; i <= n; i++){
		if(s[i-1] == s[i]) T.insert(i);
	}
	if(T.size() == 0){
		cout << 1 << endl;
		return 0;
	}
	
	for(int i = 0; i < 3; i++) S[i].insert(inf);
	T.insert(inf);
	
	dp[0] = 1;
	for(int i = 0; i < n; i++){
		dp[i+1] += dp[i], dp[i+1] %= mod;
		llint lb = *T.lower_bound(i+2), c = 3 - (s[i+1]-'a'+1);
		if(lb > n) continue;
		llint p = *S[(sum[i]+c)%3].lower_bound(lb);
		if(p <= n) dp[p] += dp[i], dp[p] %= mod;
	}
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		if(sum[i] == sum[n]) ans += dp[i], ans %= mod;
	}
	cout << ans << endl;
	
	/*for(int i = 0; i <= n; i++){
		for(int j = 0; j < 2; j++){
			cout << dp[i][j] << " ";
		}cout << endl;
	}*/
	
	return 0;
}