#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n;

char s[200010];
int cnt[3];

int dp[200010][3][3][3];
int dp2[200010][3][3][3];

const ll mod = 998244353;

int main()
{
	scanf("%s", s);
	n = strlen(s);
	
	if(n <= 4){
		set<string> vis;
		queue<string> q;
		q.push(s); vis.insert(s);
		while(q.size()){
			auto t=q.front(); q.pop();
			char tmp[10]; strcpy(tmp, t.c_str());
			for(int i=0; i<n-1; ++i){
				char a=tmp[i], b=tmp[i+1];
				if(a != b){
					char c = int('a')+'b'+'c'-a-b;
					tmp[i] = tmp[i+1] = c;
					if(vis.insert(tmp).second) q.push(tmp);
					tmp[i]=a; tmp[i+1]=b;
				}
			}
		}
		printf("%d\n", int(vis.size()));
		return 0;
	}
	
	for(int i=0; i<n; ++i) ++cnt[s[i]-'a'];
	
	if(cnt[0]==n || cnt[1]==n || cnt[2]==n){
		puts("1");
		return 0;
	}
	
	dp[1][1][1][0] = 1;
	dp[1][2][0][1] = 1;
	dp[1][0][2][2] = 1;
	
	dp2[1][1][1][0] = 1;
	dp2[1][2][0][1] = 1;
	dp2[1][0][2][2] = 1;
	
	
	for(int l=1; l<n; ++l){
		for(int va=0; va<3; ++va) for(int vb=0; vb<3; ++vb) for(int t=0; t<3; ++t){
			(dp[l+1][(va+1)%3][(vb+1)%3][0] += dp[l][va][vb][t]) %= mod;
			(dp[l+1][(va+2)%3][vb][1] += dp[l][va][vb][t]) %= mod;
			(dp[l+1][va][(vb+2)%3][2] += dp[l][va][vb][t]) %= mod;
			
			if(t!=0) (dp2[l+1][(va+1)%3][(vb+1)%3][0] += dp2[l][va][vb][t]) %= mod;
			if(t!=1) (dp2[l+1][(va+2)%3][vb][1] += dp2[l][va][vb][t]) %= mod;
			if(t!=2) (dp2[l+1][va][(vb+2)%3][2] += dp2[l][va][vb][t]) %= mod;
			
			
		}
	}
	
	int ka=(cnt[0]+2*cnt[1])%3, kb=(cnt[0]+2*cnt[2])%3;
	
	int ans = 1;
	for(int t=0; t<3; ++t){
		(ans += (dp[n][ka][kb][t] + mod-dp2[n][ka][kb][t]) % mod) %= mod;
	}
	
	for(int i=0; i+1<n; ++i) if(s[i]==s[i+1]){
		(ans += mod-1) %= mod;
		break;
	}
	
	printf("%d\n", ans);
	return 0;
}

### Prompt

Develop a solution in Cpp to the problem described below:

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>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n;

char s[200010];
int cnt[3];

int dp[200010][3][3][3];
int dp2[200010][3][3][3];

const ll mod = 998244353;

int main()
{
	scanf("%s", s);
	n = strlen(s);
	
	if(n <= 4){
		set<string> vis;
		queue<string> q;
		q.push(s); vis.insert(s);
		while(q.size()){
			auto t=q.front(); q.pop();
			char tmp[10]; strcpy(tmp, t.c_str());
			for(int i=0; i<n-1; ++i){
				char a=tmp[i], b=tmp[i+1];
				if(a != b){
					char c = int('a')+'b'+'c'-a-b;
					tmp[i] = tmp[i+1] = c;
					if(vis.insert(tmp).second) q.push(tmp);
					tmp[i]=a; tmp[i+1]=b;
				}
			}
		}
		printf("%d\n", int(vis.size()));
		return 0;
	}
	
	for(int i=0; i<n; ++i) ++cnt[s[i]-'a'];
	
	if(cnt[0]==n || cnt[1]==n || cnt[2]==n){
		puts("1");
		return 0;
	}
	
	dp[1][1][1][0] = 1;
	dp[1][2][0][1] = 1;
	dp[1][0][2][2] = 1;
	
	dp2[1][1][1][0] = 1;
	dp2[1][2][0][1] = 1;
	dp2[1][0][2][2] = 1;
	
	
	for(int l=1; l<n; ++l){
		for(int va=0; va<3; ++va) for(int vb=0; vb<3; ++vb) for(int t=0; t<3; ++t){
			(dp[l+1][(va+1)%3][(vb+1)%3][0] += dp[l][va][vb][t]) %= mod;
			(dp[l+1][(va+2)%3][vb][1] += dp[l][va][vb][t]) %= mod;
			(dp[l+1][va][(vb+2)%3][2] += dp[l][va][vb][t]) %= mod;
			
			if(t!=0) (dp2[l+1][(va+1)%3][(vb+1)%3][0] += dp2[l][va][vb][t]) %= mod;
			if(t!=1) (dp2[l+1][(va+2)%3][vb][1] += dp2[l][va][vb][t]) %= mod;
			if(t!=2) (dp2[l+1][va][(vb+2)%3][2] += dp2[l][va][vb][t]) %= mod;
			
			
		}
	}
	
	int ka=(cnt[0]+2*cnt[1])%3, kb=(cnt[0]+2*cnt[2])%3;
	
	int ans = 1;
	for(int t=0; t<3; ++t){
		(ans += (dp[n][ka][kb][t] + mod-dp2[n][ka][kb][t]) % mod) %= mod;
	}
	
	for(int i=0; i+1<n; ++i) if(s[i]==s[i+1]){
		(ans += mod-1) %= mod;
		break;
	}
	
	printf("%d\n", ans);
	return 0;
}

```