#include <bits/stdc++.h>
const int N = 100005, P = 1e9 + 7;
char s[N];
int sum[N], f[N], pre[N], n, flag;
int main() {
  scanf("%s", &s);
  n = strlen(s);
  for (int i = 1; i < n; ++i)
    if (s[i] == s[i - 1]) {
      flag = 1;
      break;
    }
  if (!flag) {
    puts("1");
    return 0;
  }
  for (int i = 0; i < n; ++i) sum[i + 1] = (s[i] == 'a' ? 1 : 2);
  for (int i = 2; i <= n; ++i) sum[i] += sum[i - 1];
  f[n] = 1;
  for (int i = 0; i <= 2; ++i) pre[i] = (i == sum[n] ? n : n + 1);
  for (int i = n - 1; i; --i) {
    f[i] = (sum[i] == sum[n]);
    for (int j = 1; j <= 2; ++j) f[i] = (f[i] + f[pre[(sum[i] + j) % 3]]) % P;
    pre[sum[i]] = i;
  }
  printf("%d\n", (f[pre[1]] + f[pre[2]]) % P);
  return 0;
}
