#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
string s;
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
int main() {
  cin >> s;
  int n = (int)s.size();
  vector<int> sum(n + 1, 0);
  for (int i = 0; i < n; ++i) {
    int par = (s[i] == 'a' ? 1 : 2);
    sum[i + 1] = (sum[i] + par) % 3;
  }
  vector<vector<int> > next(n + 1, vector<int>(3, n + 1));
  for (int i = n - 1; i >= 0; --i) {
    next[i][sum[i + 1]] = i + 1;
    for (int j = 0; j < 3; ++j) next[i][j] = min(next[i][j], next[i + 1][j]);
  }
  vector<int> next2(n + 1, n);
  for (int i = n - 2; i >= 0; --i) {
    if (s[i] == s[i + 1])
      next2[i] = i + 1;
    else
      next2[i] = min(next2[i], next2[i + 1]);
  }
  vector<long long> dp(n + 1, 0);
  dp[0] = 1;
  for (int i = 0; i <= n; ++i) {
    add(dp[i + 1], dp[i]);
    int wa;
    if (s[i] == 'a')
      wa = 2;
    else
      wa = 1;
    int ne = next[next2[i]][(sum[i] + (s[i] == 'a' ? 2 : 1)) % 3];
    if (ne <= n) add(dp[ne], dp[i]);
  }
  long long res = 0;
  if (next2[0] == n)
    res = 1;
  else {
    for (int i = 1; i <= n; ++i) {
      if (sum[i] == sum[n]) add(res, dp[i]);
    }
  }
  cout << res << endl;
}
