#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 2;
const long long mod = 1e9 + 7;
long long dp[N], sum[N][3], last[3];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  long long n, i, j, k, l = 0;
  cin >> s;
  n = s.size();
  s = " " + s;
  dp[0] = 1;
  sum[0][0] = 1;
  last[1] = -1;
  last[2] = -1;
  bool cac = true;
  for (i = 1; i <= n; i++) {
    if (s[i] == s[i - 1]) {
      cac = false;
    }
    if (s[i] == 'a') {
      l++;
    } else {
      l += 2;
    }
    if (l >= 3) {
      l -= 3;
    }
    for (j = 0; j < 3; j++) {
      sum[i][j] = sum[i - 1][j];
      dp[i] += sum[i][j];
      if (last[l] > -1) {
        dp[i] -= sum[last[l]][j];
      }
    }
    dp[i] -= sum[i][l];
    if (last[l] > -1) {
      dp[i] += sum[last[l]][l];
    }
    dp[i] = (dp[i] % mod + mod) % mod;
    last[l] = i;
    sum[i][l] += dp[i];
  }
  if (cac) {
    cout << 1;
    return 0;
  }
  if (!l) {
    sum[n][l]--;
  }
  cout << sum[n][l];
}
