#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
using namespace std;
void _main();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  _main();
}
const int inf = INT_MAX / 2;
const long long infl = 1LL << 60;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <int MOD>
struct ModInt {
  static const int Mod = MOD;
  unsigned x;
  ModInt() : x(0) {}
  ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
  ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
  int get() const { return (int)x; }
  ModInt &operator+=(ModInt that) {
    if ((x += that.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt &operator-=(ModInt that) {
    if ((x += MOD - that.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt &operator*=(ModInt that) {
    x = (unsigned long long)x * that.x % MOD;
    return *this;
  }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
  ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
  ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
  ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
  ModInt inverse() const {
    long long a = x, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b;
      std::swap(a, b);
      u -= t * v;
      std::swap(u, v);
    }
    return ModInt(u);
  }
  bool operator==(ModInt that) const { return x == that.x; }
  bool operator!=(ModInt that) const { return x != that.x; }
  ModInt operator-() const {
    ModInt t;
    t.x = x == 0 ? 0 : Mod - x;
    return t;
  }
};
template <int MOD>
ostream &operator<<(ostream &st, const ModInt<MOD> a) {
  st << a.get();
  return st;
};
template <int MOD>
ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
  ModInt<MOD> r = 1;
  while (k) {
    if (k & 1) r *= a;
    a *= a;
    k >>= 1;
  }
  return r;
}
string S;
int N;
ModInt<1000000007> dp[101010];
int sm[101010], nxt[101010][3];
int ok[101010], oksm[101010];
vector<int> idx[3];
int getok(int l, int r) {
  if (l >= r) return 0;
  int res = oksm[r - 1];
  if (l) res -= oksm[l - 1];
  return res;
}
void _main() {
  cin >> S;
  N = S.length();
  for (int i = 0; i < N; i++) {
    if (S[i] == 'a')
      sm[i] = 1;
    else
      sm[i] = 2;
  }
  for (int i = 1; i < N; i++) sm[i] = (sm[i] + sm[i - 1]) % 3;
  for (int i = 0; i < N; i++) idx[sm[i]].push_back(i);
  for (int i = 0; i < 3; i++) idx[i].push_back(N);
  for (int i = 0; i < N - 1; i++)
    if (S[i] == S[i + 1]) ok[i] = 1;
  oksm[0] = ok[0];
  for (int i = 1; i < N; i++) oksm[i] = oksm[i - 1] + ok[i];
  for (int i = 0; i < N; i++) {
    for (int c = 0; c < 3; c++) {
      int ng = i, ok = N;
      while (ng + 1 != ok) {
        int md = (ng + ok) / 2;
        int j = *lower_bound((idx[c]).begin(), (idx[c]).end(), md);
        if (getok(i, j))
          ok = md;
        else
          ng = md;
      }
      nxt[i][c] = *lower_bound((idx[c]).begin(), (idx[c]).end(), ok);
    }
  }
  dp[0] = 1;
  for (int i = 0; i < N; i++) {
    int pre = 0;
    if (i) pre = sm[i - 1];
    if (S[i] == 'a')
      dp[i + 1] += dp[i];
    else {
      int ai = nxt[i][(pre + 1) % 3];
      if (ai < N) dp[ai + 1] += dp[i];
    }
    if (S[i] == 'b')
      dp[i + 1] += dp[i];
    else {
      int bi = nxt[i][(pre + 2) % 3];
      if (bi < N) dp[bi + 1] += dp[i];
    }
  }
  ModInt<1000000007> ans = 0;
  for (int i = 1; i < N + 1; i++)
    if ((sm[N - 1] - sm[i - 1] + 3) % 3 == 0) ans += dp[i];
  cout << ans << endl;
}
