#include <bits/stdc++.h>
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c <= '9' && c >= '0') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
void print(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
const int maxn = 100007;
char t[maxn];
int n, s[maxn];
int f[maxn];
const int mod = 1e9 + 7;
int main() {
  scanf("%s", t + 1);
  n = strlen(t + 1);
  bool flag = false;
  for (int i = 2; i <= n; ++i)
    if (t[i] == t[i - 1]) flag = true;
  if (!flag) {
    puts("1");
    return 0;
  }
  int now = 0, pre[3] = {0, -1, -1};
  f[0] = 1;
  for (int i = 1; i <= n; ++i) {
    now = (now + 2 - (t[i] == 'a')) % 3;
    if (!now && i < n) f[i] = 1;
    ++now, now %= 3;
    if (pre[now] != -1) (f[i] += f[pre[now]]) %= mod;
    ++now, now %= 3;
    if (pre[now] != -1) (f[i] += f[pre[now]]) %= mod;
    ++now, now %= 3;
    pre[now] = i;
  }
  print(f[n]);
}
