#include <bits/stdc++.h>
//#pragma comment(linker, "/STACK:1024000000,1024000000") 
#define MOD 998244353
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
#define rep(i,l,r) for(int i=l;i<r;i++)
using namespace std;
string s;
int n,sum;
long long dp[200005][3][3],ans=1;
bool flag=1;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s;
	n=s.length();
	sum=s[0]-'a';
	for(int i=1;i<n;i++){
		(sum+=s[i]-'a')%=3;
		flag&=(s[i]==s[i-1]);
		(ans*=3ll)%=MOD;
	}
	if(flag){
		cout<<"1\n";
		return 0;
	}
	if(n<=3){
		if(n==2)cout<<"2\n";
		else{
			if(s[0]==s[1] || s[1]==s[2])cout<<"6\n";
			else if(s[0]==s[2])cout<<"7\n";
			else cout<<"3\n";
		}
		return 0;
	}
	dp[0][0][0]=dp[0][1][1]=dp[0][2][2]=1;
	rep(i,1,n)rep(j,0,3)rep(k,0,3)rep(l,0,3){
		if(k!=l)(dp[i][(j+l)%3][l]+=dp[i-1][j][k])%=MOD;
	}
	for(int i=0;i<3;i++)(ans+=MOD-dp[n-1][sum][i])%=MOD;
	for(int i=1;i<n;i++){
		if(s[i]==s[i-1]){
			(ans+=MOD-1)%=MOD;
			break;
		}
	}
	cout<<(ans+1)%MOD<<endl;
	return 0;
}
### Prompt

Please create a solution in CPP to the following problem:

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>
//#pragma comment(linker, "/STACK:1024000000,1024000000") 
#define MOD 998244353
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
#define rep(i,l,r) for(int i=l;i<r;i++)
using namespace std;
string s;
int n,sum;
long long dp[200005][3][3],ans=1;
bool flag=1;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s;
	n=s.length();
	sum=s[0]-'a';
	for(int i=1;i<n;i++){
		(sum+=s[i]-'a')%=3;
		flag&=(s[i]==s[i-1]);
		(ans*=3ll)%=MOD;
	}
	if(flag){
		cout<<"1\n";
		return 0;
	}
	if(n<=3){
		if(n==2)cout<<"2\n";
		else{
			if(s[0]==s[1] || s[1]==s[2])cout<<"6\n";
			else if(s[0]==s[2])cout<<"7\n";
			else cout<<"3\n";
		}
		return 0;
	}
	dp[0][0][0]=dp[0][1][1]=dp[0][2][2]=1;
	rep(i,1,n)rep(j,0,3)rep(k,0,3)rep(l,0,3){
		if(k!=l)(dp[i][(j+l)%3][l]+=dp[i-1][j][k])%=MOD;
	}
	for(int i=0;i<3;i++)(ans+=MOD-dp[n-1][sum][i])%=MOD;
	for(int i=1;i<n;i++){
		if(s[i]==s[i-1]){
			(ans+=MOD-1)%=MOD;
			break;
		}
	}
	cout<<(ans+1)%MOD<<endl;
	return 0;
}
```