#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=201000;
int nxt[N][10],s[N];
ll dp[N];
int solve(VI c) {
	bool ss=0;
	rep(i,0,SZ(c)-1)  if (c[i]==c[i+1]) ss=1;
	if (!ss) return 1;
	int n=SZ(c);
	rep(i,0,n) s[i+1]=(s[i]+(c[i]?1:2))%3;
	rep(j,0,3) nxt[n][j]=n+1;
	per(i,0,n) {
		rep(j,0,3) nxt[i][j]=nxt[i+1][j];
		nxt[i][s[i+1]]=i+1;
	}
	dp[0]=1;
	ll ans=0;
	rep(i,1,n+1) dp[i]=0;
	rep(i,0,n+1) {
		rep(j,1,3) {
			int p=nxt[i][(s[i]+j)%3];
			if (p<=n) {
				dp[p]=(dp[p]+dp[i])%mod;
			}
		}
		if (i>0&&s[i]==s[n]) ans=(ans+dp[i])%mod;
	}
//	printf("%lld\n",ans);
	return ans;
}

char ss[N];
//int M=10;
int main() {
	scanf("%s",ss);
	int n=strlen(ss);
	VI c;
	rep(i,0,n) c.pb(ss[i]-'a');
	printf("%d\n",solve(c));
/*
	rep(S,0,(1<<M)) {
		VI c;
		rep(i,0,M) c.pb((S>>i)&1);
		set<VI> w;
		queue<VI> q;
		q.push(c);
		w.insert(c);
		while (!q.empty()) {
			VI cc=q.front(); q.pop();
			rep(i,0,SZ(cc)-1) if (cc[i]==cc[i+1]) {
				VI dd=cc; dd.erase(dd.begin()+i);
				dd[i]^=1;
				if (!w.count(dd)) w.insert(dd),q.push(dd);
			}
		}
		rep(i,0,M) printf("%c",'a'+c[i]); printf(" %d\n",SZ(w));
		assert(SZ(w)==solve(c));
	}*/
}
