#include <bits/stdc++.h>
using namespace std;
int read() {
  char c = getchar();
  int d = 0, f = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; d = d * 10 + c - 48, c = getchar())
    ;
  return d * f;
}
char Read() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  return c;
}
const int N = 100000;
const int mod = 1e9 + 7;
int n, dp[N + 1], a[N + 1], t[N + 1][3], tt[N + 1], p[10];
char s[N + 1];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) a[i] = (s[i] == 'a' ? 1 : 2);
  for (int i = 1; i <= n; ++i) (a[i] += a[i - 1]) %= 3;
  for (int i = n; i >= 1; --i) {
    for (int j = 0; j <= 2; ++j) t[i][j] = t[i + 1][j];
    t[i][a[i]] = i;
    tt[i] = tt[i + 1];
    if (i < n && (a[i - 1] + a[i + 1] - 2 * a[i]) % 3 == 0) tt[i] = i + 1;
  }
  dp[0] = 1;
  for (int i = 0; i <= n - 1; ++i)
    if (dp[i]) {
      p[0] = 0;
      p[++p[0]] = i + 1;
      if (tt[i + 1])
        for (int j = 0; j <= 2; ++j)
          if (j != a[i] && j != a[i + 1]) p[++p[0]] = t[tt[i + 1]][j];
      if (tt[i + 1] && a[n] != a[i]) {
        p[++p[0]] = n;
        for (int j = 1; j <= p[0] - 1; ++j)
          if (p[j] == n) p[0]--;
      }
      for (int j = 1; j <= p[0]; ++j) (dp[p[j]] += dp[i]) %= mod;
      if (i && i != n - 1 && !tt[i + 1] && (i % 2 != n % 2))
        (dp[n] += (mod + dp[i] - dp[i - 1]) % mod) %= mod;
    }
  cout << dp[n] << endl;
}
