#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
const int mo = 1000000007;
int n, ans;
char s[N];
int las[N], S[N];
int suf[N][3], f[N];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  bool fl = 0;
  for (int i = (int)(1); i <= (int)(n - 1); i++)
    if (s[i] == s[i - 1]) fl = 1;
  if (!fl) return puts("1"), 0;
  for (int i = (int)(1); i <= (int)(n); i++)
    S[i] = (S[i - 1] + s[i] - 'a' + 1) % 3;
  for (int i = (int)(0); i <= (int)(2); i++) suf[n + 1][i] = n + 1;
  for (int i = (int)(n); i >= (int)(1); i--) {
    for (int j = (int)(0); j <= (int)(2); j++) suf[i][j] = suf[i + 1][j];
    suf[i][S[i]] = i;
  }
  f[0] = 1;
  for (int i = (int)(1); i <= (int)(n + 1); i++) {
    if (S[i - 1] == S[n] && i != 1) ans = (ans + f[i - 1]) % mo;
    int nx = suf[i + 1][3 - S[i - 1] - S[i]];
    f[i] = (f[i] + f[i - 1]) % mo;
    f[nx] = (f[nx] + f[i - 1]) % mo;
  }
  printf("%d\n", ans);
}
