#include <bits/stdc++.h>
using namespace std;
namespace RA {
int r(int p) { return 1ll * rand() * rand() % p; }
int r(int L, int R) { return r(R - L + 1) + L; }
}  // namespace RA
const int N = 1e5 + 5, P = 1e9 + 7;
int n;
char s[N];
int app_a[N], app_b[N];
int nex[N][3];
int nex_xx[N];
long long f[N];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = (1); i <= (n); ++i) s[i] = s[i] == 'a' ? 1 : 2;
  for (int i = (2); i <= (n); ++i) s[i] += s[i - 1];
  nex[n][0] = nex[n][1] = nex[n][2] = n + 1;
  nex[n + 1][0] = nex[n + 1][1] = nex[n + 1][2] = n + 1;
  for (int i = (n - 1); i >= (0); --i) {
    for (int j = (0); j <= (2); ++j)
      nex[i][j] = s[i + 1] % 3 == j ? i + 1 : nex[i + 1][j];
  }
  nex_xx[n] = nex_xx[n + 1] = n + 1;
  for (int i = (n - 1); i >= (0); --i) {
    nex_xx[i] = s[i + 1] - s[i] == s[i + 2] - s[i + 1] ? i + 1 : nex_xx[i + 1];
  }
  for (int i = (0); i <= (n); ++i) {
    app_a[i] = s[i + 1] - s[i] == 1 ? i + 1 : nex[nex_xx[i]][(s[i] + 1) % 3];
    app_b[i] = s[i + 1] - s[i] == 2 ? i + 1 : nex[nex_xx[i]][(s[i] + 2) % 3];
  }
  f[0] = 1;
  for (int i = (0); i <= (n); ++i) {
    f[app_a[i]] = (f[app_a[i]] + f[i]) % P;
    f[app_b[i]] = (f[app_b[i]] + f[i]) % P;
  }
  long long ans = 0;
  for (int i = (1); i <= (n); ++i)
    if (s[i] % 3 == s[n] % 3) ans = (ans + f[i]) % P;
  if (nex_xx[0] == n + 1)
    puts("1");
  else
    printf("%lld\n", ans);
  return 0;
}
