#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=998244353;
const int MAXN=200010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, s;
ll dp[MAXN][3][3], ans;
string S;
set<string> st;

void dfs(string S){
	st.insert(S);
	for (int i=1; i<n; i++) if (S[i]!=S[i-1]){
		string T=S;
		char ch='a'+'b'+'c'-S[i]-S[i-1];
		T[i]=T[i-1]=ch;
		if (!st.count(T)) dfs(T);
	}
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>S;
	n=S.size();
	if (n<=3){
		dfs(S);
		cout<<st.size()<<"\n";
		return 0;
	}
	for (int i=1; i<n; i++){
		if (S[i]!=S[i-1]) a=1;
		else b=1;
	}
	if (!a) kill(1)
	for (char ch:S) s=(s+ch-'a')%3;
	dp[1][0][0]=dp[1][1][1]=dp[1][2][2]=1;
	for (int i=2; i<=n; i++)
		for (int j:{0, 1, 2})
			for (int last:{0, 1, 2})
				for (int l:{0, 1, 2}) if (l!=last)
					dp[i][j][last]=(dp[i][j][last]+dp[i-1][(j+3-last)%3][l])%mod;
	ans=1;
	for (int i=2; i<=n; i++) ans=ans*3%mod;
	ans-=dp[n][s][0]+dp[n][s][1]+dp[n][s][2];
	
	if (!b) ans++;
	ans%=mod;
	if (ans<0) ans+=mod;
	cout<<ans<<"\n";
	
	return 0;
}

### Prompt

Create a solution in Cpp for 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 GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=998244353;
const int MAXN=200010, LOG=20;

int n, m, k, u, v, x, y, t, a, b, s;
ll dp[MAXN][3][3], ans;
string S;
set<string> st;

void dfs(string S){
	st.insert(S);
	for (int i=1; i<n; i++) if (S[i]!=S[i-1]){
		string T=S;
		char ch='a'+'b'+'c'-S[i]-S[i-1];
		T[i]=T[i-1]=ch;
		if (!st.count(T)) dfs(T);
	}
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>S;
	n=S.size();
	if (n<=3){
		dfs(S);
		cout<<st.size()<<"\n";
		return 0;
	}
	for (int i=1; i<n; i++){
		if (S[i]!=S[i-1]) a=1;
		else b=1;
	}
	if (!a) kill(1)
	for (char ch:S) s=(s+ch-'a')%3;
	dp[1][0][0]=dp[1][1][1]=dp[1][2][2]=1;
	for (int i=2; i<=n; i++)
		for (int j:{0, 1, 2})
			for (int last:{0, 1, 2})
				for (int l:{0, 1, 2}) if (l!=last)
					dp[i][j][last]=(dp[i][j][last]+dp[i-1][(j+3-last)%3][l])%mod;
	ans=1;
	for (int i=2; i<=n; i++) ans=ans*3%mod;
	ans-=dp[n][s][0]+dp[n][s][1]+dp[n][s][2];
	
	if (!b) ans++;
	ans%=mod;
	if (ans<0) ans+=mod;
	cout<<ans<<"\n";
	
	return 0;
}

```