#include <bits/stdc++.h>
using namespace std;
int p = 1000000007;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<vector<int> > lis(3);
  vector<int> sum(n + 1);
  bool fl = true;
  for (long long i = 0; i < n; i++) {
    lis[sum[i]].push_back(i);
    sum[i + 1] = sum[i] + (s[i] - 'a') + 1;
    sum[i + 1] %= 3;
    if (i % 2 == 0 xor s[i] == s[0]) {
      fl = false;
    }
  }
  if (fl) {
    cout << 1 << endl;
    return 0;
  }
  vector<int> dp(n);
  dp[0] = 1;
  int ans = 0;
  for (long long i = 0; i < n; i++) {
    if (sum[i] != sum[n]) {
      ans += dp[i];
    }
    int pla = (sum[i] + 1) % 3;
    auto itr = lower_bound(lis[pla].begin(), lis[pla].end(), i);
    if (itr != lis[pla].end()) {
      dp[*itr] += dp[i];
      dp[*itr] %= p;
    }
    pla++;
    pla %= 3;
    itr = lower_bound(lis[pla].begin(), lis[pla].end(), i);
    if (itr != lis[pla].end()) {
      dp[*itr] += dp[i];
      dp[*itr] %= p;
    }
  }
  cout << ans % p << endl;
}
