#include<cstdio>
#define Z int
#define C char
#define L long long
#define S(s) scanf("%s",s+1)
#define P(n) printf("%lld",(n+p)%p)
#define F(i,a,b) for(L i=a;i<=b;i++)
#define D(i,a,b) for(L i=a;i>=b;i--)
#define W while
#define I if
#define R return
#define nx 100001
#define p (L)(1e9+7)
C s[nx];
L n,g,a[nx],pre[nx],nxt[nx][3],f[nx],ans;
Z main(){
	S(s);
	W(s[n+1])n++;
	F(i,1,n)pre[i]=pre[i-1]+(a[i]=s[i]-'`');
	F(i,1,n-1)I(a[i]==a[i+1])g=1;
	I(!g){P(1);R 0;}
	D(i,n-1,0)F(o,1,2)nxt[i][(pre[i]+o)%3]=
	a[i+1]==o?i+1:nxt[i+1][(pre[i]+o)%3];
	f[0]=1;
	F(i,0,n-1)F(o,1,2)(f[nxt[i][(pre[i]+o)%3]]+=f[i])%=p;
	F(i,1,n)I((pre[n]-pre[i])%3==0)(ans+=f[i])%=p;
	P(ans);
}