#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1000005,M=998244353;
char s[N];
int flag[N],ans,dp[N][2][3][3];
int gethash(char s[]){
	int num=0;
	for (int i=1,j=1;s[i];i++,j*=3)
		num+=j*(s[i]-'a');
	return num;	
}
void dfs(char s[]){
	int k=gethash(s);
	if (flag[k])return;
	flag[k]=1;ans++;
	for (int i=1;s[i+1];i++)
		if (s[i]!=s[i+1]){
			int k1=s[i],k2=s[i+1];
			int p=s[i]^s[i+1]^97^98^99;
			s[i]=s[i+1]=p;
			dfs(s);
			s[i]=k1;s[i+1]=k2;
		}
}
signed main(){
	scanf("%s",s+1);
	if (strlen(s+1)<=3){
		dfs(s);
		printf("%lld\n",ans);
		return 0;
	}
	int flag1=0,flag=1,sum=s[1]-'a';
	for (int i=2;s[i];i++){
		if (s[i]!=s[i-1])flag1=1;
		if (s[i]==s[i-1])flag=0;
		sum+=s[i]-'a';sum%=3;
	}
	if (flag1==0){
		puts("1");
		return 0;
	}
	for (int i=0;i<=2;i++)dp[1][0][i][i]=1;
	int n=strlen(s+1);
	for (int i=1;i<n;i++)
		for (int j=0;j<=2;j++)
			for (int k=0;k<=2;k++)
				for (int l=0;l<=2;l++){
					(dp[i+1][k==l][(j+l)%3][l]+=dp[i][0][j][k])%=M;
					(dp[i+1][1][(j+l)%3][l]+=dp[i][1][j][k])%=M;
				}
	for (int i=0;i<=2;i++)
			(flag+=dp[n][1][sum][i])%=M;			
	printf("%d\n",flag);
}
### Prompt

Develop a solution in CPP 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>
using namespace std;
#define int long long
const int N=1000005,M=998244353;
char s[N];
int flag[N],ans,dp[N][2][3][3];
int gethash(char s[]){
	int num=0;
	for (int i=1,j=1;s[i];i++,j*=3)
		num+=j*(s[i]-'a');
	return num;	
}
void dfs(char s[]){
	int k=gethash(s);
	if (flag[k])return;
	flag[k]=1;ans++;
	for (int i=1;s[i+1];i++)
		if (s[i]!=s[i+1]){
			int k1=s[i],k2=s[i+1];
			int p=s[i]^s[i+1]^97^98^99;
			s[i]=s[i+1]=p;
			dfs(s);
			s[i]=k1;s[i+1]=k2;
		}
}
signed main(){
	scanf("%s",s+1);
	if (strlen(s+1)<=3){
		dfs(s);
		printf("%lld\n",ans);
		return 0;
	}
	int flag1=0,flag=1,sum=s[1]-'a';
	for (int i=2;s[i];i++){
		if (s[i]!=s[i-1])flag1=1;
		if (s[i]==s[i-1])flag=0;
		sum+=s[i]-'a';sum%=3;
	}
	if (flag1==0){
		puts("1");
		return 0;
	}
	for (int i=0;i<=2;i++)dp[1][0][i][i]=1;
	int n=strlen(s+1);
	for (int i=1;i<n;i++)
		for (int j=0;j<=2;j++)
			for (int k=0;k<=2;k++)
				for (int l=0;l<=2;l++){
					(dp[i+1][k==l][(j+l)%3][l]+=dp[i][0][j][k])%=M;
					(dp[i+1][1][(j+l)%3][l]+=dp[i][1][j][k])%=M;
				}
	for (int i=0;i<=2;i++)
			(flag+=dp[n][1][sum][i])%=M;			
	printf("%d\n",flag);
}
```