#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long INF = 1ll << 60;
const double pi = acos(-1);
const double eps = 1e-9;
const long long mod = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int n;
string s;
vector<int> a, S, b[3], g[2];
int main() {
  cin >> s;
  n = s.size();
  a = vector<int>(n);
  S = vector<int>(n + 1);
  b[0] = b[1] = b[2] = g[0] = g[1] = vector<int>(n + 1, -1);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'a')
      a[i] = 2;
    else
      a[i] = 1;
  }
  for (int i = 1; i <= n; i++) S[i] = S[i - 1] + a[i - 1];
  for (int i = n - 1; i >= 0; i--) {
    b[a[i]][i] = i + 1;
    for (int j = 0; j < 3; j++)
      if (j != a[i]) {
        b[j][i] = b[(j - a[j] + 3) % 3][i + 1];
      }
  }
  int I = -1;
  for (int i = n - 1; i >= 0; i--) {
    if (i != n - 1 && s[i] == s[i + 1]) I = i + 2;
    if (s[i] == 'a') {
      g[0][i] = i + 1;
      if (I == -1) continue;
      int t = (4 - S[I] + S[i]) % 3;
      if (!t)
        g[1][i] = I;
      else
        g[1][i] = b[(4 - S[I] + S[i]) % 3][I];
    } else {
      g[1][i] = i + 1;
      if (I == -1) continue;
      int t = (5 - S[I] + S[i]) % 3;
      if (!t)
        g[0][i] = I;
      else
        g[0][i] = b[(5 - S[I] + S[i]) % 3][I];
    }
  }
  int J = -1;
  for (int i = n - 2; i >= 0; i--)
    if (s[i] == s[i + 1]) {
      J = i + 2;
      break;
    }
  if (J == -1) {
    cout << 1 << endl;
    return 0;
  }
  vector<int> dp(n + 1);
  dp[0]++;
  int res = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 2; j++)
      if (g[j][i] != -1) {
        I = g[j][i];
        (dp[I] += dp[i]) %= mod;
        if ((S[n] - S[I] + 3) % 3 == 0 && (I != i + 1 || i + 1 >= I))
          (res += dp[i]) %= mod;
      }
  cout << res << endl;
}
