#include <bits/stdc++.h>
#define F(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define f(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define file(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
using namespace std;

template<typename T>bool chkmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool chkmin(T &a,T b){return (a>b)?a=b,1:0;}

inline int read() {
 int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}
int n;
char s[1000005];
int sum[1000005];
int dp[1000005];
int nxt[10];
const int mod=1e9+7;
int main () {
#ifndef ONLINE_JUDGE
//file("agc27e");
#endif
    scanf("%s",s+1);
	n=strlen(s+1);
	F(i,1,n)sum[i]=(sum[i-1]+s[i]-'a'+1)%3;
	dp[n]=1;
	bool flag=0;
	F(i,1,n-1)if(s[i]==s[i+1])flag=1;
	if(!flag){
	  puts("1");
	  return 0;
	}
	F(i,0,2)nxt[i]=i==sum[n]?n:n+1;
	f(i,n-1,1){
	  dp[i]=sum[i]==sum[n];
	  F(j,1,2){
	     dp[i]=(dp[i]+dp[nxt[(sum[i]+j)%3]])%mod;
	  }
	  nxt[sum[i]]=i;
	}
    printf("%d\n",(dp[nxt[1]]+dp[nxt[2]])%mod);
    return 0;
}