#include<bits/stdc++.h>
#define mo 998244353
#define N 200005
using namespace std;
char s[N];
int f[N][3][3];
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	if (n==2){
		printf("%d\n",1+(s[1]!=s[2]));
		return 0;
	}
	if (n==3){
		if (s[1]==s[2]&&s[2]==s[3]) puts("1");//3
		else if (s[1]==s[2]||s[2]==s[3]) puts("6");//12
		else if (s[1]==s[3]) puts("7");//6
		else puts("3");//6
		return 0;
	}
	int fl=1;
	for (int i=1;i<n;i++)
		if (s[i]!=s[i+1]) fl=0;
	if (fl){
		puts("1");
		return 0;
	}
	int ans=power(3,n-1);
	int v=0;
	for (int i=1;i<=n;i++)
		v=(v+s[i]-'a')%3;
	for (int i=0;i<3;i++)
		f[1][i][i]=1;
	for (int i=2;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 (k!=l)
						f[i][(j+l)%3][l]=(f[i][(j+l)%3][l]+f[i-1][j][k])%mo;
	for (int i=0;i<3;i++)
		ans=(ans+mo-f[n][v][i])%mo;
	fl=1;
	for (int i=1;i<n;i++)
		if (s[i]==s[i+1]) fl=0;
	printf("%d\n",(ans+fl)%mo);
}

### 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>
#define mo 998244353
#define N 200005
using namespace std;
char s[N];
int f[N][3][3];
int power(int x,int y){
	int s=1;
	for (;y;y/=2,x=1ll*x*x%mo)
		if (y&1) s=1ll*s*x%mo;
	return s;
}
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	if (n==2){
		printf("%d\n",1+(s[1]!=s[2]));
		return 0;
	}
	if (n==3){
		if (s[1]==s[2]&&s[2]==s[3]) puts("1");//3
		else if (s[1]==s[2]||s[2]==s[3]) puts("6");//12
		else if (s[1]==s[3]) puts("7");//6
		else puts("3");//6
		return 0;
	}
	int fl=1;
	for (int i=1;i<n;i++)
		if (s[i]!=s[i+1]) fl=0;
	if (fl){
		puts("1");
		return 0;
	}
	int ans=power(3,n-1);
	int v=0;
	for (int i=1;i<=n;i++)
		v=(v+s[i]-'a')%3;
	for (int i=0;i<3;i++)
		f[1][i][i]=1;
	for (int i=2;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 (k!=l)
						f[i][(j+l)%3][l]=(f[i][(j+l)%3][l]+f[i-1][j][k])%mo;
	for (int i=0;i<3;i++)
		ans=(ans+mo-f[n][v][i])%mo;
	fl=1;
	for (int i=1;i<n;i++)
		if (s[i]==s[i+1]) fl=0;
	printf("%d\n",(ans+fl)%mo);
}

```