#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod = 1e9+7;
char s[1010000];
int main(){
	ios::sync_with_stdio(0);
	cin>>s+1;
	int n=strlen(s+1);
	int flag=1;
	for(int i=1;i<=n;i++){
		if(i>1)flag&=s[i]!=s[i-1];
	}
	if(flag){cout<<1<<'\n';return 0;}
	int now=0,p[3]={0,-1,-1},f[101000]={1};
	for(int i=1;i<=n;i++){
		now=(now+s[i]-'a'+1)%3;
		if(!now&&i<n) f[i]=1;
		auto upd=[](int&a,int b){a+=b;if(a>=mod) a-=mod;};
		if(~p[(now+2)%3]) upd(f[i],f[p[(now+2)%3]]);
		if(~p[(now+1)%3]) upd(f[i],f[p[(now+1)%3]]);
		p[now]=i;
	}
	cout<<f[n]<<'\n';
	return 0;
}
