#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 1000000007
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n,a[N],lst[3];
ll f[N];
char s[N];

int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    int ok=0;
    rep(i,1,n)
    {
        a[i]=(a[i-1]+(s[i]-'a')+1)%3;
        if (s[i]==s[i-1]) ok=1;
    }
    if (!ok) {puts("1");return 0;}
    rep(i,1,n)
    {
        f[i]=(f[lst[0]]+f[lst[1]]+f[lst[2]])%maxd;
        f[i]=(f[i]-f[lst[a[i]]]+maxd)%maxd;
        if (a[i]) f[i]++;lst[a[i]]=i;
    }
    printf("%lld\n",f[n]);
    return 0;
}