#include <bits/stdc++.h>
using namespace std;
const long long MODULO = 1e9 + 7;
map<vector<int>, long long> ans;
long long Solve(int at, int sum, int want, int len, int was,
                const vector<int>& a) {
  if (at == a.size()) {
    if (sum == want) return 1;
    return 0;
  }
  vector<int> state = {at, sum, want, len, was};
  for (int x : state) cerr << x << " ";
  cerr << endl;
  if (ans.count(state)) return ans[state];
  long long& result = ans[state];
  result = 0;
  if (sum == want && want != 0 && (len == 1 || was)) {
    for (int w = 0; w < 3; ++w)
      result = (result + Solve(at, 0, w, 0, 0, a)) % MODULO;
    return result;
  }
  int newLen = min(len + 1, 2);
  int newWas = was;
  if (len != 0) newWas |= (a[at] == a[at - 1]);
  int newSum = (sum + a[at]) % 3;
  result = (result + Solve(at + 1, newSum, want, newLen, newWas, a)) % MODULO;
  return result;
}
int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool found = false;
  for (int i = 0; i < n - 1; ++i)
    if (s[i] == s[i + 1]) found = true;
  if (!found) {
    cout << 1 << endl;
    return 0;
  }
  vector<int> a(n, 1);
  for (int i = 0; i < n; ++i)
    if (s[i] == 'b') a[i] = 2;
  long long result =
      (Solve(0, 0, 1, 0, 0, a) + Solve(0, 0, 2, 0, 0, a)) % MODULO;
  cout << result << endl;
  return 0;
}
