#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 100007;
const int MOD = 1000000007;
int n;
char s[MAXN];
int dp[MAXN], ps[3];
bool hv[3];
void init();
void input();
void work();
int add(int x, int y) { return ((x += y) < MOD) ? x : (x - MOD); }
void addv(int &x, int y) { ((x += y) < MOD) ? x : (x -= MOD); }
int sub(int x, int y) { return ((x -= y) >= 0) ? x : (x + MOD); }
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() { scanf("%s", s + 1); }
void work() {
  n = strlen(s + 1);
  int np = 0;
  dp[0] = ps[0] = 1;
  for (int i = 1; i <= n; ++i) {
    (np += s[i] - 'a' + 1) %= 3;
    dp[i] = sub(add(add(ps[0], ps[1]), ps[2]), ps[np]);
    if (np && hv[0]) addv(dp[i], 1);
    ps[np] = dp[i];
    hv[np] = true;
  }
  if (!hv[0] || !hv[1] || !hv[2])
    cout << 1 << endl;
  else
    cout << dp[n] << endl;
}
