#include <bits/stdc++.h>
using namespace std;
const int inf = 1e7;
const long long mod = 1e9 + 7;
int main() {
  string s;
  cin >> s;
  int n = (int)s.size();
  bool unko = true;
  for (int i = 0; (i) < (int)(n - 1); (i)++) unko = unko && s[i] != s[i + 1];
  if (unko) {
    cout << 1 << endl;
    return 0;
  }
  vector<int> acc(n + 1);
  for (int i = 0; (i) < (int)(n); (i)++) {
    int a = (s[i] == 'a' ? 1 : 2);
    acc[i + 1] = (acc[i] + a) % 3;
  }
  vector<vector<int>> app(n + 2, vector<int>(3));
  for (int i = 0; (i) < (int)(3); (i)++) app[n + 1][i] = inf;
  for (int i = n; i >= 0; i--) {
    for (int j = 0; (j) < (int)(3); (j)++) {
      app[i][j] = (acc[i] == j ? i : app[i + 1][j]);
    }
  }
  cerr << "OK" << endl;
  long long ans = 0;
  vector<int> add(n + 1);
  add[0] = 1;
  for (int i = 0; (i) < (int)(n + 1); (i)++) {
    if (acc[n] == acc[i]) (ans += add[i]) %= mod;
    for (int put = 1; put <= 2; put++) {
      int pos = app[i + 1][(put + acc[i]) % 3];
      if (pos != inf) (add[pos] += add[i]) %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}
