#include <bits/stdc++.h>
using namespace std;
char s[1000005];
int sum[1000005], last[1000005], dp[1000005], nxt[1000005][3];
inline int gt(char ch) {
  if (ch == 'a') return 1;
  return 2;
}
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  bool flag = 1;
  for (int i = 1; i <= n; i++) {
    if (s[i] == s[i - 1]) flag = 0;
    sum[i] = sum[i - 1] + gt(s[i]);
    sum[i] %= 3;
  }
  if (flag) return puts("-1"), 0;
  for (int i = 0; i < 3; i++) last[i] = n + 1;
  for (int i = n; ~i; i--) {
    for (int j = 0; j < 3; j++) nxt[i][j] = last[j];
    last[sum[i]] = i;
  }
  int ans = 0;
  dp[0] = 1;
  for (int i = 0; i <= n; i++) {
    for (int j = 1; j <= 2; j++)
      if (nxt[i][(sum[i] + j) % 3] <= n)
        dp[nxt[i][(sum[i] + j) % 3]] =
            1ll * (dp[nxt[i][(sum[i] + j) % 3]] + dp[i]) % 1000000007;
    if (i && sum[i] == sum[n]) ans = 1ll * (ans + dp[i]) % 1000000007;
  }
  printf("%d\n", ans);
  return 0;
}
