//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 1e5 + 20 , mod = 1e9 + 7 ;
int n , dp[N] , sum[N] , nxt[N][2] , last[3] , tlast[3] ;
string s ;

inline void add (int &a , int b) {
	a += b ;
	if (a >= mod) a -= mod ;
}

int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> s ;
	n = _sz(s) ;

	for (int i = 0 ; i < n ; i ++) {
		if (i == n - 1) return cout << "1\n" , 0 ;
		if (s[i] == s[i + 1]) break ;
	}

	last[0] = last[1] = last[2] = n + 2 ;
	tlast[0] = n ;

	for (int i = n - 1 ; i >= 0 ; i --) {
		sum[i] = (sum[i + 1] + (s[i] - 'a' + 1)) % 3 ;

		nxt[i][0] = last[(sum[i] + 2) % 3] ;
		nxt[i][1] = last[(sum[i] + 1) % 3] ;

		if (s[i] == 'a') nxt[i][0] = i + 1 ;
		if (s[i] == 'b') nxt[i][1] = i + 1 ;

		if (i && s[i - 1] == s[i]) {
			for (int j = 0 ; j < 3 ; j ++) last[j] = tlast[j] ;
		}
		
		tlast[sum[i]] = i ;
	}

	dp[0] = 1 ;
	for (int i = 0 ; i < n ; i ++) {
		add(dp[nxt[i][0]] , dp[i]) ;
		add(dp[nxt[i][1]] , dp[i]) ;
	}

	int ans = 0 ;
	for (int i = 1 ; i <= n ; i ++) 
		if (sum[i] == 0) add(ans , dp[i]) ;

	cout << ans << '\n' ;
}