#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<complex>
#include<cmath>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
const int mod=998244353;
int dp[200005][3][3][2];
int n;
char str[200005];
int main()
{
	scanf("%s",str);
	n=strlen(str);
	bool as=1;
	for(int i=1;i<n;i++)
		as&=(str[i-1]==str[i]);
	if(as)
	{
		printf("1\n");
		return 0;
	}
	if(n==3)
	{
		int ans=0;
		if(str[0]!=str[1] && str[1]!=str[2] && str[0]!=str[2])	ans=3;
		else if(str[0]==str[2])	ans=7;
		else	ans=6;
		cout<<ans<<endl;
		return 0;
	}
	dp[1][0][0][0]=1;
	dp[1][1][1][0]=1;
	dp[1][2][2][0]=1;
	for(int i=1;i<n;i++)
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
				for(int l=0;l<3;l++)
				{
					if(l==k)
						dp[i+1][(j+l)%3][l][1]=(0ll+dp[i+1][(j+l)%3][l][1]+dp[i][j][k][0]+dp[i][j][k][1])%mod;
					else
					{
						dp[i+1][(j+l)%3][l][1]=(dp[i+1][(j+l)%3][l][1]+dp[i][j][k][1])%mod;
						dp[i+1][(j+l)%3][l][0]=(dp[i+1][(j+l)%3][l][0]+dp[i][j][k][0])%mod;
					}
				}
	bool gg=0;
	for(int i=1;i<n;i++)
		if(str[i-1]==str[i])	gg=1;
	int rr=0;
	for(int i=0;i<n;i++)
		rr=(rr+str[i]-'a')%3;
	int ans=0;
	for(int i=0;i<3;i++)
		ans=(ans+dp[n][rr][i][1])%mod;
	if(!gg)	ans++;
	ans%=mod;
	cout<<ans<<endl;
	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
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<bitset>
#include<complex>
#include<cmath>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
const int mod=998244353;
int dp[200005][3][3][2];
int n;
char str[200005];
int main()
{
	scanf("%s",str);
	n=strlen(str);
	bool as=1;
	for(int i=1;i<n;i++)
		as&=(str[i-1]==str[i]);
	if(as)
	{
		printf("1\n");
		return 0;
	}
	if(n==3)
	{
		int ans=0;
		if(str[0]!=str[1] && str[1]!=str[2] && str[0]!=str[2])	ans=3;
		else if(str[0]==str[2])	ans=7;
		else	ans=6;
		cout<<ans<<endl;
		return 0;
	}
	dp[1][0][0][0]=1;
	dp[1][1][1][0]=1;
	dp[1][2][2][0]=1;
	for(int i=1;i<n;i++)
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
				for(int l=0;l<3;l++)
				{
					if(l==k)
						dp[i+1][(j+l)%3][l][1]=(0ll+dp[i+1][(j+l)%3][l][1]+dp[i][j][k][0]+dp[i][j][k][1])%mod;
					else
					{
						dp[i+1][(j+l)%3][l][1]=(dp[i+1][(j+l)%3][l][1]+dp[i][j][k][1])%mod;
						dp[i+1][(j+l)%3][l][0]=(dp[i+1][(j+l)%3][l][0]+dp[i][j][k][0])%mod;
					}
				}
	bool gg=0;
	for(int i=1;i<n;i++)
		if(str[i-1]==str[i])	gg=1;
	int rr=0;
	for(int i=0;i<n;i++)
		rr=(rr+str[i]-'a')%3;
	int ans=0;
	for(int i=0;i<3;i++)
		ans=(ans+dp[n][rr][i][1])%mod;
	if(!gg)	ans++;
	ans%=mod;
	cout<<ans<<endl;
	return 0;
}
```