#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const long long p = 1e9 + 7;
const long long inf = (1 << 30);
string s;
long long v[MAXN], dp[MAXN][3], part[MAXN][3][3], r[MAXN][3], n;
vector<int> pos[3];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  n = s.length();
  v[0] = 0;
  for (int i = 1; i <= n; ++i) v[i] = (v[i - 1] + 1 + (s[i - 1] == 'b')) % 3;
  n++;
  for (int i = 0; i < n; ++i) pos[v[i]].push_back(i);
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j < 3; ++j) {
      if (v[i] == j)
        r[i][j] = i;
      else
        r[i][j] = max(i + 1LL, r[i + 1][j]);
    }
  }
  dp[0][0] = 1;
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < 3; ++j)
      for (int k = 0; k < 3; ++k) {
        if (v[i] != k && v[i - 1] == j)
          part[i][j][k] = (part[i - 1][j][k] + dp[i - 1][j]) % p;
        else
          part[i][j][k] = part[i - 1][j][k];
      }
    for (int j = 0; j < 3; ++j) {
      if (v[i] == j) continue;
      int k = 3 - v[i] - j;
      int lo = 0, hi = pos[j].size();
      if (pos[j].size() == 0) continue;
      while (lo != hi) {
        int mid = (lo + hi) / 2;
        int x = pos[j][mid];
        if (r[x][k] >= i) {
          hi = mid;
          continue;
        }
        if (r[r[x][k]][v[i]] >= i)
          hi = mid;
        else
          lo = mid + 1;
      }
      if (lo == pos[j].size()) continue;
      int val1 = pos[j][lo];
      lo = -1, hi = pos[j].size() - 1;
      while (lo != hi) {
        int mid = (lo + hi + 1) / 2;
        int x = pos[j][mid];
        if (r[x][k] > i) {
          hi = mid - 1;
          continue;
        }
        if (r[r[x][k]][v[i]] > i)
          hi = mid - 1;
        else
          lo = mid;
      }
      if (lo == -1) continue;
      int val2 = pos[j][lo];
      if (val1 > val2) continue;
      dp[i][v[i]] =
          (dp[i][v[i]] + part[val2 + 1][j][v[i]] + p - part[val1][j][v[i]]) % p;
    }
    dp[i][v[i]] = (dp[i][v[i]] + dp[i - 1][v[i - 1]]) % p;
  }
  long long ans = 0;
  for (int i = 0; i < n - 2; ++i) {
    if (v[i] == v[n - 1]) continue;
    int k = 3 - v[i] - v[n - 1];
    if (r[i][k] >= n) continue;
    if (r[r[i][k]][v[n - 1]] >= n) continue;
    ans = (ans + dp[i][v[i]]) % p;
  }
  ans = (ans + dp[n - 2][v[n - 2]]) % p;
  int g = -1;
  for (int i = n - 1; i >= -1; --i) {
    if (i == -1) g = -1;
    if (v[i] == v[n - 2]) g = i;
    if (v[i] == 3 - v[n - 2] - v[n - 1]) break;
  }
  if (g != -1) {
    for (int k = g; k < n - 2; k += 2) ans = (ans + dp[g][v[g]]) % p;
  }
  cout << ans << endl;
}
