#include <bits/stdc++.h>
const int mu=998244353,N=200005;
long long dp[N][3][3][2];
char s[N];
int n,r,l;
int check(){
	int t=0;
	for (int i=1;i<l;i++) if (s[i]==s[i-1]) t++;
	if (t==l-1) return 2;
	if (t) return 0;
	return 1;
}
int main(){
	scanf("%s",s);
	l=strlen(s);
	if (l==1){
		puts("1");
		return 0;
	}
	if(l==2){
		if (s[0]==s[1]) puts("1");
		else puts("2");
		return 0;
	} 
	if (l==3){
		if (s[0]!=s[1] && s[1]!=s[2] && s[0]!=s[2])
		puts("3");
		else if (s[0]==s[1] && s[1]==s[2]) puts("1");
		else if (s[0]==s[1] && s[1]!=s[2]) puts("6");
		else if (s[0]!=s[1] && s[1]==s[2]) puts("6");
		else puts("7");
		return 0;
	}
	for (int i=0;i<l;i++) r=(r+s[i]-'0')%3;
	//printf("%d\n",r);
	int tt=check();
	if(tt==2) {
		puts("1");
		return 0;
	}
	dp[1][1][1][0]=dp[1][0][0][0]=dp[1][2][2][0]=1;
	for (int i=1;i<=l;i++)
		for(int j=0;j<=2;j++)//上一位 
			for (int k=0;k<=2;k++)//余数 
				for (int now=0;now<=2;now++)//这一位 
				{
					int t=(now+j)%3,rk=(k+now)%3;
					if (now==j) dp[i+1][now][rk][1]=(dp[i+1][now][rk][1]+dp[i][j][k][0]+dp[i][j][k][1])%mu;
					else {
						(dp[i+1][now][rk][1]+=dp[i][j][k][1])%=mu;
						(dp[i+1][now][rk][0]+=dp[i][j][k][0])%=mu;
					}
				}			
	printf("%d\n",(dp[l][1][r][1]+dp[l][0][r][1]+dp[l][2][r][1]+tt)%mu);	 
}
### Prompt

Please provide a Cpp coded solution to the problem described below:

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 <bits/stdc++.h>
const int mu=998244353,N=200005;
long long dp[N][3][3][2];
char s[N];
int n,r,l;
int check(){
	int t=0;
	for (int i=1;i<l;i++) if (s[i]==s[i-1]) t++;
	if (t==l-1) return 2;
	if (t) return 0;
	return 1;
}
int main(){
	scanf("%s",s);
	l=strlen(s);
	if (l==1){
		puts("1");
		return 0;
	}
	if(l==2){
		if (s[0]==s[1]) puts("1");
		else puts("2");
		return 0;
	} 
	if (l==3){
		if (s[0]!=s[1] && s[1]!=s[2] && s[0]!=s[2])
		puts("3");
		else if (s[0]==s[1] && s[1]==s[2]) puts("1");
		else if (s[0]==s[1] && s[1]!=s[2]) puts("6");
		else if (s[0]!=s[1] && s[1]==s[2]) puts("6");
		else puts("7");
		return 0;
	}
	for (int i=0;i<l;i++) r=(r+s[i]-'0')%3;
	//printf("%d\n",r);
	int tt=check();
	if(tt==2) {
		puts("1");
		return 0;
	}
	dp[1][1][1][0]=dp[1][0][0][0]=dp[1][2][2][0]=1;
	for (int i=1;i<=l;i++)
		for(int j=0;j<=2;j++)//上一位 
			for (int k=0;k<=2;k++)//余数 
				for (int now=0;now<=2;now++)//这一位 
				{
					int t=(now+j)%3,rk=(k+now)%3;
					if (now==j) dp[i+1][now][rk][1]=(dp[i+1][now][rk][1]+dp[i][j][k][0]+dp[i][j][k][1])%mu;
					else {
						(dp[i+1][now][rk][1]+=dp[i][j][k][1])%=mu;
						(dp[i+1][now][rk][0]+=dp[i][j][k][0])%=mu;
					}
				}			
	printf("%d\n",(dp[l][1][r][1]+dp[l][0][r][1]+dp[l][2][r][1]+tt)%mu);	 
}
```