#include <bits/stdc++.h>

using namespace std;

const int md = 1e9 + 7;

int add(int x, int y) {
  x += y;
  if (x >= md) {
    x -= md;
  }
  return x;
}

int main() {
#ifdef wxh010910
  freopen("input.txt", "r", stdin);
#endif
  string s;
  cin >> s;
  int n = s.length();
  bool flag = true;
  for (int i = 1; i < n; ++i) {
    flag &= s[i] != s[i - 1];
  }
  if (flag) {
    puts("1");
    return 0;
  }
  vector<int> sum(n + 1);
  for (int i = 0; i < n; ++i) {
    sum[i + 1] = (sum[i] + (s[i] == 'a') + 1) % 3;
  }
  vector<vector<int>> next(n + 1, vector<int> (3, n + 1));
  for (int i = n - 1; ~i; --i) {
    for (int j = 0; j < 3; ++j) {
      next[i][j] = next[i + 1][j];
    }
    next[i][sum[i + 1]] = i + 1;
  }
  vector<int> f(n + 1);
  int answer = 0;
  f[0] = 1;
  for (int i = 0; i <= n; ++i) {
    for (int j = 1; j <= 2; ++j) {
      if (next[i][(sum[i] + j) % 3] <= n) {
        f[next[i][(sum[i] + j) % 3]] = add(f[next[i][(sum[i] + j) % 3]], f[i]);
      }
    }
    if (i && sum[i] == sum[n]) {
      answer = add(answer, f[i]);
    }
  }
  printf("%d\n", answer);
  return 0;
}
