#include <bits/stdc++.h>
using namespace std;
char str[100005];
int nxt[100005][3];
int dp[100005];
int memo[3];
long long int solve(vector<int> vec) {
  int n = vec.size();
  memset(memo, -1, sizeof(memo));
  for (int i = n - 1; i >= 0; i--) {
    memo[vec[i]] = i;
    for (int t = 0; t < 3; t++) nxt[i][t] = memo[t];
  }
  for (int i = 0; i <= n; i++) dp[i] = 0;
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int t = 0; t < 3; t++) {
      if (t == vec[i]) continue;
      if (nxt[i][t] != -1) {
        dp[nxt[i][t]] += dp[i];
        if (dp[nxt[i][t]] >= 1000000007) dp[nxt[i][t]] -= 1000000007;
      }
    }
  }
  long long int ret = 0;
  for (int i = 1; i < n; i++) {
    if (vec[i] == vec[n - 1]) {
      ret += dp[i];
      if (ret >= 1000000007) ret -= 1000000007;
    }
  }
  return ret;
}
int main() {
  scanf("%s", &str);
  int n = strlen(str);
  int sum = 0;
  vector<int> vec;
  vec.push_back(0);
  for (int i = 0; i < n; i++) {
    if (str[i] == 'a')
      sum += 2;
    else
      sum++;
    sum %= 3;
    vec.push_back(sum);
  }
  long long int ret = 1;
  vector<int> now;
  for (int i = 0; i < vec.size(); i++) {
    if (now.size() >= 1 && now[now.size() - 1] == vec[i]) {
      ret = ret * solve(now);
      ret %= 1000000007;
      now.clear();
    }
    now.push_back(vec[i]);
  }
  ret = ret * solve(now);
  ret %= 1000000007;
  printf("%lld\n", ret);
  return 0;
}
