#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
using namespace std;
const long long N = 2e5 + 100, mod = 1e9 + 7;
long long long long nxt[N];
long long long long b[N][3];
long long long long d[N][3];
long long long long a[N];
long long long long dp[N];
long long long long par[N];
int32_t main() {
  string s;
  cin >> s;
  long long long long n = s.size();
  for (long long i = 0; i < s.size(); i++) {
    a[i + 1] = s[i] - 'a' + 1;
  }
  nxt[n] = n + 1;
  for (long long i = n - 1; i; i--) {
    if (a[i + 1] == a[i])
      nxt[i] = i + 1;
    else
      nxt[i] = nxt[i + 1];
  }
  b[n + 1][0] = n + 1;
  b[n + 1][1] = n + 1;
  b[n + 1][2] = n + 1;
  b[n + 2][0] = n + 2;
  b[n + 2][1] = n + 2;
  b[n + 2][2] = n + 2;
  d[n + 1][0] = n + 1;
  d[n + 1][1] = n + 1;
  d[n + 1][2] = n + 1;
  d[n + 2][0] = n + 2;
  d[n + 2][1] = n + 2;
  d[n + 2][2] = n + 2;
  for (long long i = n; i; i--) {
    if (a[i] == 1) {
      b[i][1] = i;
      long long long long z = nxt[i];
      z--;
      long long long long y = (z - i + 2) / 2 + ((z - i + 1) / 2) * 2;
      y %= 3;
      if (y == 2) {
        b[i][2] = d[z + 1][0];
      }
      if (y == 0) {
        b[i][2] = b[z + 1][2];
      }
      if (y == 1) {
        b[i][2] = b[z + 1][1];
      }
    } else if (a[i] == 2) {
      b[i][2] = i;
      long long long long z = nxt[i];
      z--;
      long long long long y = ((z - i + 2) / 2) * 2 + (z - i + 1) / 2;
      y %= 3;
      if (y == 1) {
        b[i][1] = d[z + 1][0];
      }
      if (y == 0) {
        b[i][1] = b[z + 1][1];
      }
      if (y == 2) {
        b[i][1] = b[z + 1][2];
      }
    }
    for (long long j = 0; j < 3; j++) {
      if (j == a[i]) {
        d[i][j] = i;
        continue;
      }
      long long long long z = j + a[i];
      z %= 3;
      d[i][j] = d[i + 1][z];
    }
    for (long long j = 0; j < 3; j++) {
      if (b[i][j] > n || b[i][j] == 0) b[i][j] = n + 1;
      if (d[i][j] > n || d[i][j] == 0) d[i][j] = n + 1;
    }
  }
  for (long long i = n; i; i--) par[i] = a[i] + par[i + 1], par[i] %= 3;
  for (long long i = n; i; i--) {
    if (par[i]) dp[i]++;
    dp[i] += dp[b[i][1] + 1];
    dp[i] += dp[b[i][2] + 1];
    dp[i] %= mod;
  }
  cout << dp[1] << '\n';
}
