#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B>
bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
signed main() {
  string s;
  cin >> s;
  int n = s.size(), MOD = 1000000007;
  bool h = true;
  for (int i = 0; i < n - 1; i++)
    if (s[i] == s[i + 1]) h = false;
  if (h) {
    cout << 1 << endl;
    return 0;
  }
  vector<int> c(n + 1);
  for (int i = 0; i < n; i++) c[i + 1] = s[i] - 'a' + 1;
  for (int i = 0; i < n; i++) (c[i + 1] += c[i]) %= 3;
  vector<int> dp(n + 1);
  dp[0] = 1;
  for (int i = 0; i < n; i++)
    if (dp[i]) {
      for (int q = 0; q < 2; q++) {
        if (s[i] - 'a' == q) {
          (dp[i + 1] += dp[i]) %= MOD;
          continue;
        }
        h = false;
        for (int j = i + 1; j < n + 1; j++) {
          if (j - i - 1 && s[j - 1] == s[j - 2]) h = true;
          if (h && q + 1 == (c[j] + 3 - c[i]) % 3) {
            (dp[j] += dp[i]) %= MOD;
            break;
          }
        }
      }
    }
  int out = 0;
  for (int i = 0; i < n; i++)
    if ((c[n] + 3 - c[i + 1]) % 3 == 0) (out += dp[i + 1]) %= MOD;
  cout << out << endl;
}
