#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int read() {
  char c = getchar();
  int tot = 1;
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    tot = -1;
    c = getchar();
  }
  int sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum * tot;
}
inline void wr(int x) {
  if (x < 0) {
    putchar('-');
    wr(-x);
    return;
  }
  if (x >= 10) wr(x / 10);
  putchar(x % 10 + '0');
}
inline void wrn(int x) {
  wr(x);
  putchar('\n');
}
inline void wri(int x) {
  wr(x);
  putchar(' ');
}
inline void wrn(int x, int y) {
  wri(x);
  wrn(y);
}
inline void wrn(int a, int b, int c) {
  wri(a);
  wrn(b, c);
}
int n, m, a[500055], l[500055], dp[500055], sum[500055];
char str[500055];
inline void add(int &x, int k) {
  x += k;
  x -= (x >= 1000000007) ? 1000000007 : 0;
}
signed main() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  for (int i = (1); i <= (n); i++) a[i] = (str[i] == 'a') ? 1 : 2;
  int pd = 0;
  for (int i = (1); i <= (n - 2); i++) pd |= (a[i] == a[i + 1]);
  if (!pd) return puts("1"), 0;
  ;
  l[1] = l[2] = -1;
  dp[0] = 1;
  for (int i = (1); i <= (n); i++) {
    sum[i] = sum[i - 1] + a[i];
    if (sum[i] % 3 == 0 && i < n) dp[i] = 1;
    for (int j = (1); j <= (2); j++) {
      if (l[(sum[i] + 3 - j) % 3] != -1)
        add(dp[i], dp[l[(sum[i] + 3 - j) % 3]]);
    }
    l[sum[i] % 3] = i;
  }
  wrn(dp[n]);
  return 0;
}
