//Love and Freedom.
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<string>
#define ll long long
#define inf 20021225
#define N 200010
#define mdn 998244353 
using namespace std;
int read()
{
	int s=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return f*s;
}
int f[N][3][3][2],n,ans; char ch[N]; string gg; map<string,bool> vis;
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
void dfs(string a)
{
	if(vis[a])	return;
	string qwq=a; ans++; vis[a]=1;
	for(int i=0;i<n-1;i++)	if(qwq[i]!=qwq[i+1])
	{
		if((qwq[i]=='a' && qwq[i+1]=='b')||(qwq[i]=='b'&&qwq[i+1]=='a'))
			a[i]=a[i+1]='c',dfs(a),a[i]=qwq[i],a[i+1]=qwq[i+1];
		if((qwq[i]=='a' && qwq[i+1]=='c')||(qwq[i]=='c'&&qwq[i+1]=='a'))
			a[i]=a[i+1]='b',dfs(a),a[i]=qwq[i],a[i+1]=qwq[i+1]; 
		if((qwq[i]=='b' && qwq[i+1]=='c')||(qwq[i]=='c'&&qwq[i+1]=='b'))
			a[i]=a[i+1]='a',dfs(a),a[i]=qwq[i],a[i+1]=qwq[i+1]; 
	}
}
int main()
{
	scanf("%s",ch+1); n=strlen(ch+1);
	if(n<=3)
	{
		for(int i=1;i<=n;i++)	gg=gg+ch[i];
		dfs(gg),printf("%d\n",ans); return 0;
	}
	int flag=0,fs=ch[1]-'a';
	for(int i=2;i<=n;i++)	flag+=(ch[i]==ch[i-1]),(fs+=ch[i]-'a')%=3;
	if(flag==n-1)	return puts("1"),0;
	f[1][0][0][0]=1; f[1][1][1][0]=1; f[1][2][2][0]=1;
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<3;j++)	for(int k=0;k<3;k++)
			for(int s=0;s<3;s++)	for(int p=0;p<2;p++)
			{
				int np=(j==k)|p,ns=(k+s)%3;
				upd(f[i][k][ns][np],f[i-1][j][s][p]); 
			}
	}
	int ans=((ll)f[n][0][fs][1]+f[n][1][fs][1]+f[n][2][fs][1]+(!flag))%mdn;
	printf("%d\n",ans);
	return 0;
}
### Prompt

Your challenge is to write a CPP solution to the following problem:

You are given a string S consisting of `a`,`b` and `c`. Find the number of strings that can be possibly obtained by repeatedly performing the following operation zero or more times, modulo 998244353:

* Choose an integer i such that 1\leq i\leq |S|-1 and the i-th and (i+1)-th characters in S are different. Replace each of the i-th and (i+1)-th characters in S with the character that differs from both of them (among `a`, `b` and `c`).

Constraints

* 2 \leq |S| \leq 2 × 10^5
* S consists of `a`, `b` and `c`.

Input

Input is given from Standard Input in the following format:


S


Output

Print the number of strings that can be possibly obtained by repeatedly performing the operation, modulo 998244353.

Examples

Input

abc


Output

3


Input

abbac


Output

65


Input

babacabac


Output

6310


Input

ababacbcacbacacbcbbcbbacbaccacbacbacba


Output

148010497

### Response

```cpp
//Love and Freedom.
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<string>
#define ll long long
#define inf 20021225
#define N 200010
#define mdn 998244353 
using namespace std;
int read()
{
	int s=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return f*s;
}
int f[N][3][3][2],n,ans; char ch[N]; string gg; map<string,bool> vis;
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
void dfs(string a)
{
	if(vis[a])	return;
	string qwq=a; ans++; vis[a]=1;
	for(int i=0;i<n-1;i++)	if(qwq[i]!=qwq[i+1])
	{
		if((qwq[i]=='a' && qwq[i+1]=='b')||(qwq[i]=='b'&&qwq[i+1]=='a'))
			a[i]=a[i+1]='c',dfs(a),a[i]=qwq[i],a[i+1]=qwq[i+1];
		if((qwq[i]=='a' && qwq[i+1]=='c')||(qwq[i]=='c'&&qwq[i+1]=='a'))
			a[i]=a[i+1]='b',dfs(a),a[i]=qwq[i],a[i+1]=qwq[i+1]; 
		if((qwq[i]=='b' && qwq[i+1]=='c')||(qwq[i]=='c'&&qwq[i+1]=='b'))
			a[i]=a[i+1]='a',dfs(a),a[i]=qwq[i],a[i+1]=qwq[i+1]; 
	}
}
int main()
{
	scanf("%s",ch+1); n=strlen(ch+1);
	if(n<=3)
	{
		for(int i=1;i<=n;i++)	gg=gg+ch[i];
		dfs(gg),printf("%d\n",ans); return 0;
	}
	int flag=0,fs=ch[1]-'a';
	for(int i=2;i<=n;i++)	flag+=(ch[i]==ch[i-1]),(fs+=ch[i]-'a')%=3;
	if(flag==n-1)	return puts("1"),0;
	f[1][0][0][0]=1; f[1][1][1][0]=1; f[1][2][2][0]=1;
	for(int i=2;i<=n;i++)
	{
		for(int j=0;j<3;j++)	for(int k=0;k<3;k++)
			for(int s=0;s<3;s++)	for(int p=0;p<2;p++)
			{
				int np=(j==k)|p,ns=(k+s)%3;
				upd(f[i][k][ns][np],f[i-1][j][s][p]); 
			}
	}
	int ans=((ll)f[n][0][fs][1]+f[n][1][fs][1]+f[n][2][fs][1]+(!flag))%mdn;
	printf("%d\n",ans);
	return 0;
}
```