#include <bits/stdc++.h>
using namespace std;
int b[100001], c[100001], n, i, j, k, l;
char a[100002];
long long f[100001], g[100001];
int main() {
  scanf("%s", a + 1), n = strlen(a + 1);
  for (i = 1; i <= n; i++)
    b[i] = (b[i - 1] + ((a[i] == 'a') ? 1 : -1) + 3) % 3,
    c[i] = c[i - 1] + (a[i] != a[i + 1]);
  for (i = 1; i <= n; i++) {
    for (j = i - 1; j >= 1; j--)
      if ((b[j] + 1) % 3 == b[i] &&
          (c[i - 1] - c[j] != i - j - 1 || j + 1 == i)) {
        f[i] = ((f[i]) + (g[j])) % 1000000007;
        break;
      }
    if (b[i] == 1 && (c[i - 1] != i - 1 || i == 1))
      f[i] = ((f[i]) + (1)) % 1000000007;
    for (j = i - 1; j >= 1; j--)
      if ((b[j] + 2) % 3 == b[i] &&
          (c[i - 1] - c[j] != i - j - 1 || j + 1 == i)) {
        f[i] = ((f[i]) + (g[j])) % 1000000007;
        break;
      }
    if (b[i] == 2 && (c[i - 1] != i - 1 || i == 1))
      f[i] = ((f[i]) + (1)) % 1000000007;
    if (c[i - 1] == i - 1)
      g[i] = (i + 1) / 2;
    else
      g[i] = f[i];
  }
  printf("%lld\n", f[n]);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
