#include <bits/stdc++.h>
using namespace std;
const int N = 233333, mo = 1e9 + 7;
char S[N];
int n, f[N], s[N], qz[N], b[N];
vector<int> a[3];
void add(int &x, int y) { x = x + y < mo ? x + y : x + y - mo; }
int main() {
  scanf("%s", S + 1);
  n = strlen(S + 1);
  for (int i = 1; i <= n; i++) s[i] = S[i] - 'a' + 1;
  for (int i = 1; i <= n; i++)
    qz[i] = (qz[i - 1] + s[i]) % 3, a[qz[i]].push_back(i);
  f[0] = 1;
  for (int i = n, j = n + 1; i >= 0; i--) {
    if (s[i] == s[i + 1]) j = i + 1;
    b[i] = j;
  }
  for (int i = 0; i <= n - 1; i++)
    for (int j = 1; j <= 2; j++) {
      if (s[i + 1] == j)
        add(f[i + 1], f[i]);
      else if (((int)a[(qz[i] + j) % 3].size()) &&
               b[i + 1] <= a[(qz[i] + j) % 3].back()) {
        int k = *lower_bound(a[(qz[i] + j) % 3].begin(),
                             a[(qz[i] + j) % 3].end(), b[i + 1]);
        if (k <= n) add(f[k], f[i]);
      }
    }
  int res = 0;
  for (int i = 0; i <= n - 1; i++)
    if (b[i + 1] <= n && (qz[n] - qz[i]) % 3 || (qz[n - 1] - qz[i]) % 3 == 0)
      add(res, f[i]);
  printf("%d", res);
  return 0;
}
