#include <bits/stdc++.h>
using namespace std;
int n;
char s[100010];
int sum[100010][2];
int nxt[100010][2][3];
int f[100010];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) s[i] -= 'a';
  bool spj = 1;
  for (int i = 1; i < n && spj; ++i) spj &= (s[i] != s[i + 1]);
  if (spj) {
    printf("0\n");
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    sum[i][0] = sum[i - 1][0] + (s[i] == 0);
    sum[i][1] = sum[i - 1][1] + (s[i] == 1);
  }
  nxt[n + 1][0][0] = nxt[n + 1][0][1] = nxt[n + 1][0][2] = nxt[n + 1][1][0] =
      nxt[n + 1][1][1] = nxt[n + 1][1][2] = n + 1;
  for (int i = n; i >= 1; --i) {
    memcpy(nxt[i], nxt[i + 1], sizeof nxt[i]);
    nxt[i][0][(sum[i][0] + i) % 3] = i;
    nxt[i][1][(sum[i][1] + i) % 3] = i;
  }
  f[0] = 1;
  long long ans = 0;
  for (int i = 0; i < n; ++i)
    for (int c = 0; c < 2; ++c) {
      int d = (sum[i][c ^ 1] + i + 1) % 3, j = nxt[i + 1][c ^ 1][d];
      if (j <= n) (f[j] += f[i]) %= 1000000007;
      if ((sum[n][c ^ 1] + n) % 3 == (sum[i][c ^ 1] + i + 1) % 3)
        (ans += f[i]) %= 1000000007;
    }
  printf("%lld\n", ans);
  return 0;
}
