#include <bits/stdc++.h>
using namespace std;
int n;
int f[100005];
char a[100005];
inline void inc(int &x, int y) {
  x += y, x -= x >= 1000000007 ? 1000000007 : 0;
}
int main() {
  scanf("%s", a + 1);
  n = strlen(a + 1);
  bool t = 0;
  for (int i = 1; i <= n - 1; ++i)
    if (a[i] == a[i + 1]) {
      t = 1;
      break;
    }
  if (!t) return puts("1"), 0;
  int ans = 0;
  int s = 0, pre[3] = {0, -1, -1};
  f[0] = 1;
  for (int i = 1; i <= n; ++i) {
    s = (s + 2 - (a[i] == 'a')) % 3;
    ++s, s %= 3;
    if (pre[s] != -1) inc(f[i], f[pre[s]]);
    ++s, s %= 3;
    if (pre[s] != -1) inc(f[i], f[pre[s]]);
    ++s, s %= 3;
    pre[s] = i;
  }
  cout << f[n] << endl;
}
