#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

typedef long long ll;

const int MAX_N=2e5,MOD=998244353;

string S;

ll dp[MAX_N][3][3][2];

map<string,bool> mp;

char c(char a,char b){
	REP(i,3){
		if (a!='a'+i && b!='a'+i){
			return 'a'+i;
		}
	}
	return 0;
}

void solve(){
	int n=S.size();
	bool flg=true;
	REP(i,n-1){
		if (S[i]!=S[i+1]){
			flg=false;
		}
	}
	if (flg){
		cout<<1<<endl;
		return;
	}
	if (n<=3){
		mp[S]=true;
		queue<string> que;
		que.push(S);
		while(!que.empty()){
			string s=que.front();
			que.pop();
			REP(i,n-1){
				if (s[i]!=s[i+1]){
					string t=s;
					t[i]=t[i+1]=c(s[i],s[i+1]);
					if (mp.find(t)==mp.end()){
						mp[t]=true;
						que.push(t);
					}
				}
			}
		}
		cout<<mp.size()<<endl;
		return;
	}
	REP(i,3){
		REP(j,3){
			dp[0][i][j][1]=0;
			dp[0][i][j][0]=(i==j ? 1 : 0);
		}
	}
	REP(i,n-1){
		REP(j,3){
			REP(k,3){
				dp[i+1][j][k][0]=(dp[i][(j+1)%3][(k-j+3)%3][0]+dp[i][(j+2)%3][(k-j+3)%3][0])%MOD;
				REP(l,3){
					dp[i+1][j][k][1]+=dp[i][l][(k-j+3)%3][1];
					dp[i+1][j][k][1]%=MOD;
				}
				dp[i+1][j][k][1]+=dp[i][j][(k-j+3)%3][0];
				dp[i+1][j][k][1]%=MOD;
			}
		}
	}
	int s=0;
	REP(i,n){
		s+=(S[i]-'a');
	}
	s%=3;
	ll ans=0;
	REP(i,3){
		ans+=dp[n-1][i][s][1];
	}
	flg=false;
	REP(i,n-1){
		if (S[i]==S[i+1]){
			flg=true;
		}
	}
	if (!flg){
		ans++;
	}
	ans%=MOD;
	cout<<ans<<endl;
}

int main(){
	cin>>S;
	solve();
	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>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

typedef long long ll;

const int MAX_N=2e5,MOD=998244353;

string S;

ll dp[MAX_N][3][3][2];

map<string,bool> mp;

char c(char a,char b){
	REP(i,3){
		if (a!='a'+i && b!='a'+i){
			return 'a'+i;
		}
	}
	return 0;
}

void solve(){
	int n=S.size();
	bool flg=true;
	REP(i,n-1){
		if (S[i]!=S[i+1]){
			flg=false;
		}
	}
	if (flg){
		cout<<1<<endl;
		return;
	}
	if (n<=3){
		mp[S]=true;
		queue<string> que;
		que.push(S);
		while(!que.empty()){
			string s=que.front();
			que.pop();
			REP(i,n-1){
				if (s[i]!=s[i+1]){
					string t=s;
					t[i]=t[i+1]=c(s[i],s[i+1]);
					if (mp.find(t)==mp.end()){
						mp[t]=true;
						que.push(t);
					}
				}
			}
		}
		cout<<mp.size()<<endl;
		return;
	}
	REP(i,3){
		REP(j,3){
			dp[0][i][j][1]=0;
			dp[0][i][j][0]=(i==j ? 1 : 0);
		}
	}
	REP(i,n-1){
		REP(j,3){
			REP(k,3){
				dp[i+1][j][k][0]=(dp[i][(j+1)%3][(k-j+3)%3][0]+dp[i][(j+2)%3][(k-j+3)%3][0])%MOD;
				REP(l,3){
					dp[i+1][j][k][1]+=dp[i][l][(k-j+3)%3][1];
					dp[i+1][j][k][1]%=MOD;
				}
				dp[i+1][j][k][1]+=dp[i][j][(k-j+3)%3][0];
				dp[i+1][j][k][1]%=MOD;
			}
		}
	}
	int s=0;
	REP(i,n){
		s+=(S[i]-'a');
	}
	s%=3;
	ll ans=0;
	REP(i,3){
		ans+=dp[n-1][i][s][1];
	}
	flg=false;
	REP(i,n-1){
		if (S[i]==S[i+1]){
			flg=true;
		}
	}
	if (!flg){
		ans++;
	}
	ans%=MOD;
	cout<<ans<<endl;
}

int main(){
	cin>>S;
	solve();
	return 0;
}

```