#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool chkmax(T &a, T b) {
  return (a < b) ? a = b, 1 : 0;
}
template <typename T>
bool chkmin(T &a, T b) {
  return (a > b) ? a = b, 1 : 0;
}
inline int read() {
  int x = 0, fh = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') fh = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
  return x * fh;
}
int n;
char s[1000005];
int sum[1000005];
int dp[1000005];
int nxt[10];
const int mod = 1e9 + 7;
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = (1), _end_ = (int)(n); i <= _end_; ++i)
    sum[i] = (sum[i - 1] + s[i] - 'a' + 1) % 3;
  dp[n] = 1;
  for (int i = (0), _end_ = (int)(2); i <= _end_; ++i)
    nxt[i] = i == sum[n] ? n : n + 1;
  for (int i = (n - 1), _end_ = (int)(1); i >= _end_; --i) {
    dp[i] = sum[i] == sum[n];
    for (int j = (1), _end_ = (int)(2); j <= _end_; ++j) {
      dp[i] = (dp[i] + dp[nxt[(sum[i] + j) % 3]]) % mod;
    }
    nxt[sum[i]] = i;
  }
  printf("%d\n", (dp[nxt[1]] + dp[nxt[2]]) % mod);
  return 0;
}
