#include <bits/stdc++.h>
using namespace std;

const int N = 100010;
const int mod = 1e9 + 7;

char s[N]; int pre[N], dp[N], nxt[3];

int main() {
    scanf("%s", s + 1); int n = strlen(s + 1);
    for (int i = 1; i <= n; i++) 
        pre[i] = (pre[i - 1] + s[i] - 'a' + 1) % 3;
    bool flag = true;
    for (int i = 2; i <= n; i++)
        if (s[i] == s[i - 1]) {
            flag = false; break;
        }
    if (flag) return puts("1"), 0;
    nxt[0] = nxt[1] = nxt[2] = n + 1, dp[n + 1] = 1;
    for (int i = n; i >= 1; i--) {
        if (pre[i - 1] == pre[n] && i != 1) dp[i] = 1;
        dp[i] = (dp[i] + dp[i + 1]) % mod;
        int nw = s[i] - 'a' + 1, t = (pre[i - 1] + 3 - nw) % 3;
        dp[i] = (dp[i] + dp[nxt[t] + 1]) % mod, nxt[pre[i]] = i;
    }
    printf("%d\n", dp[1]);
}