#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
char s[100005];
int n, f[100005], nx[100005][2], sum = 0;
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  f[n + 1] = 1;
  nx[n + 1][0] = nx[n + 1][1] = nx[n + 2][0] = nx[n + 2][1] = n + 2;
  for (int i = n; i >= 1; i--) {
    sum = (sum + (s[i] - 'a' + 1)) % 3;
    nx[i][0] =
        (s[i] == 'a') ? i + 1 : ((s[i + 1] == 'b') ? i + 2 : nx[i + 2][0]);
    nx[i][1] =
        (s[i] == 'b') ? i + 1 : ((s[i + 1] == 'a') ? i + 2 : nx[i + 2][1]);
    f[i] = (f[nx[i][0]] + f[nx[i][1]] + (sum == 0)) % mod;
  }
  printf("%d\n", (f[1] - (sum == 0) + mod) % mod);
}
