#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
  long long x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  return x * f;
}
inline void write(long long x) {
  if (x < 0) x = -x, putchar('-');
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
const int maxn = 1e5 + 233;
const int mod = 1e9 + 7;
void add(int &x, int v) {
  x += v;
  if (x >= mod) x -= mod;
}
char t[maxn];
int n, ans, s[maxn], dp[maxn], nxt[maxn][3];
int main() {
  scanf("%s", t + 1);
  n = strlen(t + 1);
  bool flag = 0;
  for (register int i = (1); i <= int(n - 1); ++i)
    if (s[i] == s[i + 1]) flag = 1;
  if (!flag) return puts("1"), 0;
  for (register int i = (1); i <= int(n); ++i) s[i] = t[i] - 'a' + 1;
  for (register int i = (1); i <= int(n + 1); ++i) s[i] = (s[i] + s[i - 1]) % 3;
  for (register int i = (0); i <= int(2); ++i) nxt[n + 1][i] = n + 1;
  for (register int i = (n); i >= int(1); --i) {
    for (register int j = (0); j <= int(2); ++j) nxt[i][j] = nxt[i + 1][j];
    nxt[i][s[i]] = i;
  }
  dp[1] = 1;
  for (register int i = (1); i <= int(n + 1); ++i) {
    for (register int k = (1); k <= int(2); ++k)
      if (nxt[i][(s[i - 1] + k) % 3] != n + 1)
        add(dp[nxt[i][(s[i - 1] + k) % 3] + 1], dp[i]);
    if (s[i - 1] == s[n] && i != 1) add(ans, dp[i]);
  }
  writeln(ans);
}
