#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

const ll mod = 1e9 + 7;
char ch[maxn];
int n,a[maxn],s[maxn],nxt[maxn][3],id[3];
ll f[maxn];

inline void up(ll &x,ll y) { x = (x + y) % mod; }

bool check(){
	rep(i,1,n - 1) if ( a[i] == a[i + 1] ) return 0;
	return 1;
}
int main(){
	scanf("%s",ch + 1);
	n = strlen(ch + 1);
	rep(i,1,n) a[i] = ch[i] - 'a' + 1 , s[i] = (s[i - 1] + a[i]) % 3;
	if ( check() ){ 
		printf("1\n");
		return 0;
	}
	id[0] = id[1] = id[2] = n + 1;
	repd(i,n,0){
		rep(j,0,2) nxt[i][j] = id[j];
		id[s[i]] = i;
	}	
	ll ans = 0;
	f[0] = 1;
	rep(i,0,n - 1){
		up(f[nxt[i][(s[i] + 1) % 3]],f[i]);
		up(f[nxt[i][(s[i] + 2) % 3]],f[i]);
		if ( i && (s[n] - s[i] + 3) % 3 == 0 ) up(ans,f[i]);
	}
	up(ans,f[n]);
	cout<<ans<<endl;
}
