#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long n;
long long t[100005];
long long u[100005];
long long dp[100005];
string s;
long long eq[100005];
long long find0[100005];
long long find1[100005];
long long find2[100005];
int main() {
  cin >> s;
  n = s.size();
  for (int i = 1; i <= n; i++) {
    t[i] = (s[i] == 'a' ? 1 : 2);
  }
  for (int i = 1; i <= n; i++) {
    u[i] = u[i - 1] + t[i];
    u[i] %= 3;
  }
  for (int i = n; i >= 1; i--) {
    find0[i] = find0[i + 1];
    find1[i] = find1[i + 1];
    find2[i] = find2[i + 1];
    if (u[i] == 0) find0[i] = i;
    if (u[i] == 1) find1[i] = i;
    if (u[i] == 2) find2[i] = i;
  }
  for (int i = n; i >= 2; i--) {
    if (s[i - 1] == s[i]) {
      eq[i] = i;
    } else {
      eq[i] = eq[i + 1];
    }
  }
  long long ans = 0, tmp;
  dp[n + 1] = 1;
  for (int i = n; i >= 1; i--) {
    dp[i] = 1;
    if (eq[i] == 0) {
      continue;
    }
    if (u[i - 1] == 0) tmp = find1[i];
    if (u[i - 1] == 1) tmp = find2[i];
    if (u[i - 1] == 2) tmp = find0[i];
    if (i == tmp && eq[i + 1] == 0) tmp = 0;
    if (i < tmp) tmp = max(tmp, eq[i + 1]);
    if (tmp != 0) {
      dp[i] += dp[tmp + 1];
      dp[i] %= mod;
    }
    if (u[i - 1] == 0) tmp = find2[i];
    if (u[i - 1] == 1) tmp = find0[i];
    if (u[i - 1] == 2) tmp = find1[i];
    if (i == tmp && eq[i + 1] == 0) tmp = 0;
    if (i < tmp) tmp = max(tmp, eq[i + 1]);
    if (tmp != 0) {
      dp[i] += dp[tmp + 1];
      dp[i] %= mod;
    }
  }
  cout << dp[0] << endl;
  return 0;
}
