// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9,mod=998244353;
char s[200005];
int dp[200005][4][4][2],n,a[200005];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	if(n<=3){
		if(n==2){
			if(s[1]==s[2])puts("1");
			else puts("2");
			return 0;
		}else{
			if(s[1]==s[2]&&s[2]==s[3])puts("1");
			if(s[1]==s[2]&&s[2]!=s[3])puts("6");
			if(s[1]!=s[2]&&s[2]==s[3])puts("6");
			if(s[1]!=s[2]&&s[1]==s[3])puts("7");
			if(s[1]!=s[2]&&s[2]!=s[3]&&s[1]!=s[3])puts("3");
		}
		return 0;
	}
	int su=0,ok=1,ok2=1;
	for(int i=1;i<=n;i++)a[i]=s[i]-'a',su+=a[i];
	for(int i=2;i<=n;i++)ok&=(a[i]!=a[i-1]),ok2&=(a[i]==a[i-1]);
	if(ok2)return puts("1"),0;
	for(int i=0;i<=2;i++)dp[1][i][i][0]=1;
//	for(int i=1;i<)
	for(int i=2;i<=n;i++){
		for(int j=0;j<=2;j++){
//			(dp[i][(j+a[i])%3][a[i]][1] += dp[i-1][j][a[i]][0]) %= mod; 
//			for(int l=0;l<=2;l++)
//				if(l!=a[i])(dp[i][(j+l)%3][l][0] += dp[i-1][j][a[i]][0]) %= mod;
			for(int l=0;l<=2;l++)
				for(int lst=0;lst<=2;lst++){
					if(l == lst)(dp[i][(j+l)%3][l][1] += dp[i-1][j][lst][0])%=mod;
					else (dp[i][(j+l)%3][l][0] += dp[i-1][j][lst][0])%=mod;
					(dp[i][(j+l)%3][l][1] += dp[i-1][j][lst][1]) %= mod;
				}
		}
	}
//	printf("2  %d\n",dp[2][])
	int ans=0;
	for(int i=0;i<=2;i++)(ans+=dp[n][su%3][i][1])%=mod;
	printf("%d\n",ans+ok);

	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
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9,mod=998244353;
char s[200005];
int dp[200005][4][4][2],n,a[200005];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	if(n<=3){
		if(n==2){
			if(s[1]==s[2])puts("1");
			else puts("2");
			return 0;
		}else{
			if(s[1]==s[2]&&s[2]==s[3])puts("1");
			if(s[1]==s[2]&&s[2]!=s[3])puts("6");
			if(s[1]!=s[2]&&s[2]==s[3])puts("6");
			if(s[1]!=s[2]&&s[1]==s[3])puts("7");
			if(s[1]!=s[2]&&s[2]!=s[3]&&s[1]!=s[3])puts("3");
		}
		return 0;
	}
	int su=0,ok=1,ok2=1;
	for(int i=1;i<=n;i++)a[i]=s[i]-'a',su+=a[i];
	for(int i=2;i<=n;i++)ok&=(a[i]!=a[i-1]),ok2&=(a[i]==a[i-1]);
	if(ok2)return puts("1"),0;
	for(int i=0;i<=2;i++)dp[1][i][i][0]=1;
//	for(int i=1;i<)
	for(int i=2;i<=n;i++){
		for(int j=0;j<=2;j++){
//			(dp[i][(j+a[i])%3][a[i]][1] += dp[i-1][j][a[i]][0]) %= mod; 
//			for(int l=0;l<=2;l++)
//				if(l!=a[i])(dp[i][(j+l)%3][l][0] += dp[i-1][j][a[i]][0]) %= mod;
			for(int l=0;l<=2;l++)
				for(int lst=0;lst<=2;lst++){
					if(l == lst)(dp[i][(j+l)%3][l][1] += dp[i-1][j][lst][0])%=mod;
					else (dp[i][(j+l)%3][l][0] += dp[i-1][j][lst][0])%=mod;
					(dp[i][(j+l)%3][l][1] += dp[i-1][j][lst][1]) %= mod;
				}
		}
	}
//	printf("2  %d\n",dp[2][])
	int ans=0;
	for(int i=0;i<=2;i++)(ans+=dp[n][su%3][i][1])%=mod;
	printf("%d\n",ans+ok);

	return 0;
}

```