#include<bits/stdc++.h>
#define N 500005
const int mod = 1e9+7;
using namespace std;
char s[N];
int n, a[N], nxt[3], f[N];
inline void solve() {
  for (int i = 0; i < 3; i++)
    if (i == a[n]) nxt[i] = n;
    else nxt[i] = n+1;
  f[n] = 1;
  for (int i = n-1; i; i--) {
    f[i] = (a[i] == a[n]);
    for (int c = 1; c <= 2; c++) {
      f[i] = (f[i] + f[nxt[(a[i]+c)%3]])%mod;
    }
    nxt[a[i]] = i;
  }
  printf("%d\n", (f[nxt[1]] + f[nxt[2]]) % mod);
}
int main() {
  scanf("%s",s+1);
  n = strlen(s+1);
  for (int i = 1; i <= n; i++) 
    a[i] = (a[i-1]+s[i]-'a'+1)%3;
  for (int i = 2; i <= n; i++)
    if (s[i] == s[i-1]) {
      solve();
      return 0;
    }
  puts("1");
  return 0;
} 