#include <bits/stdc++.h>
using namespace std;
int n, nt[100500], su[100500], nt2[100500][3], as, dp[100500];
char s[100500];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    su[i] = (su[i - 1] + s[i] - 'a' + 1) % 3;
  }
  nt[n + 1] = n + 1;
  nt2[n + 1][0] = nt2[n + 1][1] = nt2[n + 1][2] = n + 1;
  for (int i = n; i >= 0; i--) {
    nt[i] = nt[i + 1];
    nt2[i][0] = nt2[i + 1][0];
    nt2[i][1] = nt2[i + 1][1];
    nt2[i][2] = nt2[i + 2][2];
    if (s[i] == s[i + 1]) nt[i] = i + 1;
    nt2[i][su[i + 1]] = i + 1;
  }
  dp[0] = 1;
  for (int i = 0; i <= n; i++) {
    int tp = nt[i] - 1;
    if (nt[tp] == n + 1) tp = n;
    if (s[i + 1] == 'a')
      dp[nt2[tp][(2 + su[i]) % 3]] =
          (dp[nt2[tp][(2 + su[i]) % 3]] + dp[i]) % 1000000007;
    else
      dp[i + 1] = (dp[i + 1] + dp[i]) % 1000000007;
    if (s[i + 1] == 'b')
      dp[nt2[tp][(1 + su[i]) % 3]] =
          (dp[nt2[tp][(1 + su[i]) % 3]] + dp[i]) % 1000000007;
    else
      dp[i + 1] = (dp[i + 1] + dp[i]) % 1000000007;
    if (!(su[n] - su[i]) % 3 && i) as = (as + dp[i]) % 1000000007;
  }
  if (nt[0] == n + 1) as = 1;
  printf("%d\n", as);
}
