#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50, mod = 1e9 + 7;
inline void add(int &x, int y) { x = (x + y >= mod) ? (x + y - mod) : (x + y); }
char t[N];
int n, ans, s[N], f[N], pre[N][3], fir[N];
int main() {
  scanf("%s", t + 1);
  n = strlen(t + 1);
  for (int i = 1; i <= n; i++) s[i] = (s[i - 1] + t[i] - 'a' + 1) % 3;
  pre[0][0] = pre[0][1] = pre[0][2] = -1;
  for (int i = 1; i <= n; i++) {
    pre[i][0] = pre[i - 1][0];
    pre[i][1] = pre[i - 1][1];
    pre[i][2] = pre[i - 1][2];
    pre[i][s[i - 1]] = i - 1;
  }
  for (int i = 1; i <= n; i++) {
    fir[i] = fir[i - 1];
    if (t[i] == t[i - 1]) fir[i] = i;
  }
  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    int pos = fir[i] - 1;
    f[i] = f[i - 1];
    int val = (t[i] == 'a') ? 2 : 1;
    if (~pos) {
      pos = pre[pos][(s[i] - val + 3) % 3];
      if (~pos) add(f[i], f[pos]);
    }
    if (!s[i] && i != n) add(f[i], 1);
  }
  cout << f[n] << '\n';
}
