#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
char s[maxn];
int dp[maxn], sum[maxn], n, flag;
int trans[maxn][3];
int frt[maxn];
void Add(int &a, const int &b) {
  a += b;
  if (a >= mod) a -= mod;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1), dp[0] = 1;
  trans[0][0] = 0, trans[0][1] = -1, trans[0][2] = -1;
  for (register int i = 1; i <= n; ++i)
    sum[i] = (sum[i - 1] + (s[i] - 'a' + 1)) % 3;
  frt[1] = 1;
  for (register int i = 2; i <= n; ++i)
    if (s[i] != s[i - 1])
      frt[i] = frt[i - 1];
    else
      frt[i] = i;
  int from;
  dp[0] = 1;
  for (register int i = 1; i <= n; ++i) {
    Add(dp[i], dp[i - 1]);
    if (frt[i] - 1 == 0) continue;
    if (!sum[i] && i < n) dp[i] += 1;
    from = trans[frt[i] - 1][(sum[i] - (s[i] == 'a' ? 2 : 1) + 3) % 3];
    if (~from) Add(dp[i], dp[from]);
    trans[i][0] = trans[i - 1][0];
    trans[i][1] = trans[i - 1][1];
    trans[i][2] = trans[i - 1][2];
    trans[i][sum[i]] = i;
  }
  printf("%d", dp[n]);
  return 0;
}
