#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 200000
#define mod 998244353
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
char s[MN+5];
int num[3],n,same=1,diff=1;
inline int pow(int x,int k)
{
	int sum=1;
	for(;k;k>>=1,x=1LL*x*x%mod) if(k&1) sum=1LL*sum*x%mod;
	return sum;	
}
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	for(int i=2;i<=n;++i) same&=(s[i]==s[i-1]),diff&=(s[i]!=s[i-1]);
	for(int i=1;i<=n;++i) (++num[s[i]-'a'])%=3;
	if(same) return 0*puts("1");
	if(n%3==0) 
	{
		int len=((1LL*(pow(3,n)-3LL*pow(2,n-1)%mod)*(mod+1)/3)%mod+mod)%mod;
	//	cout<<"prelen="<<len<<endl;
		if(num[0]==num[1]) len=(len-pow(2,n/3)-(n==3)+mod)%mod; 
		else len=(len+pow(2,n/3-1))%mod;
		return 0*printf("%d\n",(len+diff)%mod);
	}
	int ths=(pow(3,n-1)-pow(2,n-1)+mod+diff)%mod;
	printf("%d",ths);
	return 0;
}


### Prompt

Construct a Cpp code solution to the problem outlined:

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<cstring>
#include<cstdio>
#define MN 200000
#define mod 998244353
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
char s[MN+5];
int num[3],n,same=1,diff=1;
inline int pow(int x,int k)
{
	int sum=1;
	for(;k;k>>=1,x=1LL*x*x%mod) if(k&1) sum=1LL*sum*x%mod;
	return sum;	
}
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	for(int i=2;i<=n;++i) same&=(s[i]==s[i-1]),diff&=(s[i]!=s[i-1]);
	for(int i=1;i<=n;++i) (++num[s[i]-'a'])%=3;
	if(same) return 0*puts("1");
	if(n%3==0) 
	{
		int len=((1LL*(pow(3,n)-3LL*pow(2,n-1)%mod)*(mod+1)/3)%mod+mod)%mod;
	//	cout<<"prelen="<<len<<endl;
		if(num[0]==num[1]) len=(len-pow(2,n/3)-(n==3)+mod)%mod; 
		else len=(len+pow(2,n/3-1))%mod;
		return 0*printf("%d\n",(len+diff)%mod);
	}
	int ths=(pow(3,n-1)-pow(2,n-1)+mod+diff)%mod;
	printf("%d",ths);
	return 0;
}


```