#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const long long infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read() {
  int tmp = 0, fh = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    tmp = tmp * 10 + ch - '0';
    ch = getchar();
  }
  return tmp * fh;
}
const int N = 200010, P = 1e9 + 7;
char s[N];
int num[N], f[N][3], n, tag[N], pre[N], ans, sam[N];
set<int> mp[3];
int main() {
  scanf("\n%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) num[i] = s[i] - 'a' + 1;
  for (int i = 1; i <= n; i++) {
    if (sam[i - 1] >= i)
      sam[i] = sam[i - 1];
    else {
      sam[i] = n;
      for (int j = i; j < n; j++)
        if (num[j] == num[j + 1]) {
          sam[i] = j;
          break;
        }
    }
  }
  for (int i = n; i >= 1; i--) tag[i] = tag[i + 1] | (num[i] == num[i - 1]);
  for (int i = 1; i <= n; i++) {
    pre[i] = (pre[i - 1] + num[i]) % 3;
    mp[pre[i]].insert(i);
  }
  mp[0].insert(n + 1), mp[1].insert(n + 1), mp[2].insert(n + 1);
  f[0][0] = 1;
  for (int i = 0; i < n; i++) {
    int cnt = ((f[i][0] + f[i][1]) % P + f[i][2]) % P;
    int j = *mp[(pre[i] + 1) % 3].upper_bound(sam[i + 1]);
    if (num[i + 1] == 1) j = i + 1;
    if (j <= n) {
      if (j > i + 1 || num[j] == num[j - 1])
        f[j][0] = (f[j][0] + cnt) % P;
      else
        f[j][1] = (f[j][1] + cnt) % P;
    }
    j = *mp[(pre[i] + 2) % 3].upper_bound(sam[i + 1]);
    if (num[i + 1] == 2) j = i + 1;
    if (j <= n) {
      if (j > i + 1 || num[j] == num[j - 1])
        f[j][0] = (f[j][0] + cnt) % P;
      else
        f[j][2] = (f[j][2] + cnt) % P;
    }
  }
  for (int i = 1; i <= n; i++)
    if (pre[n] - pre[i] == 0) {
      if (tag[i + 1] == 1 || i == n) ans = (ans + f[i][1] + f[i][2]) % P;
      ans = (ans + f[i][0]) % P;
    }
  printf("%d\n", ans);
  return 0;
}
