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

const int _ = 1e5 + 7 , MOD = 1e9 + 7;
char str[_]; int L , dp[_] , pos[_][3] , sum[_];

void inc(int &a , int b){a = a + b >= MOD ? a + b - MOD : a + b;}

int main(){
	scanf("%s" , str + 1); L = strlen(str + 1); bool flg = 1;
	for(int i = 1 ; i <= L ; ++i) sum[i] = (sum[i - 1] + str[i] - 'a' + 1) % 3;
	for(int i = 2 ; i <= L ; ++i) flg &= str[i] != str[i - 1];
	if(flg){puts("1"); return 0;}
	pos[L + 1][0] = pos[L + 1][1] = pos[L + 1][2] = L + 1;
	for(int i = L ; i ; --i){
		for(int j = 0 ; j < 3 ; ++j) pos[i][(j + str[i] - 'a' + 1) % 3] = pos[i + 1][j];
		pos[i][str[i] - 'a' + 1] = i;
	}
	int p = dp[0] = 1 , ans = 0;
	for(int i = 0 ; i < L ; ++i){
		inc(dp[i + 1] , dp[i]);
		while(p <= L && (p == i + 1 || str[p] != str[p - 1])) ++p;
		inc(dp[pos[p][(!(str[i + 1] - 'a') + 4 - (sum[p - 1] - sum[i])) % 3]] , dp[i]);
	}
	for(int i = 1 ; i <= L ; ++i) inc(ans , (sum[i] == sum[L]) * dp[i]);
	cout << ans; return 0;
}