#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const long long q = 1e9 + 7;
int p[MAXN], f[MAXN][3], n, g[MAXN][3];
long long dp[MAXN];
vector<int> v[MAXN];
string s;
set<int> done[3];
int ok[MAXN], ok2[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  n = s.length();
  p[0] = 0;
  for (int i = 0; i < n; ++i) p[i + 1] = (p[i] + 1 + (s[i] == 'b')) % 3;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (i == 0)
        f[i][j] = 1;
      else
        f[i][j] = max(f[i - 1][j], i + 1);
      while (true) {
        if (f[i][j] == n + 1) break;
        if (p[f[i][j]] != j)
          f[i][j]++;
        else
          break;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    int t = p[i + 1];
    int r = 3 - p[i] - t;
    int pos = f[i][r];
    v[i + 1].push_back(i);
    if (pos != n + 1) v[pos].push_back(i);
  }
  dp[0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int u : v[i]) dp[i] = (dp[i] + dp[u]) % q;
  }
  long long ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    int t = p[i + 1];
    int r = 3 - p[i] - t;
    int pos = f[i][r];
    int pos2 = f[pos][t];
    if (pos == n + 1) pos2 = n + 1;
    if (p[i] == p[n]) continue;
    if (p[n] == r) {
      if (n >= pos) ok[i] = 1;
    }
    if (p[n] == t) {
      if (n >= pos2) ok[i] = 1;
    }
  }
  ok[n - 1] = 1;
  for (int i = 0; i < n - 1; ++i) {
    int t = p[i + 1];
    int r = 3 - p[i] - t;
    int pos = f[i][r];
    int pos2 = f[pos][t];
    if (pos == n + 1) pos2 = n + 1;
    int g[3];
    g[t] = pos2, g[r] = pos;
    if (pos == n + 1) pos2 = n + 1;
    if (!ok[i + 1]) {
      if (p[i + 1] == p[n - 1]) {
        if (g[p[n - 1]] <= n - 1) ok2[i] = 1;
      }
    }
    if (pos != n + 1 && !ok[pos]) {
      if (p[pos] == p[n - 1]) {
        if (g[p[n - 1]] <= n - 1) ok2[i] = 1;
      }
    }
  }
  for (int i = 0; i < n - 1; ++i) {
    ans = (ans + (ok[i] + ok2[i]) * dp[i]) % q;
  }
  ans = (ans + dp[n - 1]) % q;
  cout << ans << endl;
}
