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

typedef long long lint;
typedef long double louble;

#define lf ('\n')

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}

	template<typename T> inline int ts(T *s)
	{
		int a=0,c=fetch();
		while(c<=32 && c!=EOF)c=fetch();
		while(c>32 && c!=EOF)s[a++]=c,c=fetch();
		s[a]=0;
		return a;
	}
}
using ae86::ty;
using ae86::ts;

const int _ = 100007 , mo = 1000000007;

int n,val[_],las[3]={0,-1,-1};
lint f[_]={0};

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);
	
	n=ts(val+1);
	for(int i=1;i<=n;i++)val[i]-='a'-1;
	
	int able=0;
	for(int i=1;i<n;i++)if(val[i]==val[i+1])able=1;
	if(!able){cout<<1<<lf;return 0;}

	f[0]=1;
	for(int i=1,now=0;i<=n;i++)
	{
		now=(now+val[i])%3;
		if(now==0 && i<n)f[i]=1;
		now=(now+1)%3;if(las[now]>=0)f[i]=(f[i]+f[las[now]])%mo;
		now=(now+1)%3;if(las[now]>=0)f[i]=(f[i]+f[las[now]])%mo;
		now=(now+1)%3,las[now]=i;
	}
	cout<<f[n]<<lf;

	return 0;
}
