#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 5;
const int mod = 998244353;

int n;
char s[N];
int dp[N][3][3][2];

set <int> st;
void solve(int dep = 0) {
	{
		int hsh = 0;
		for (int i = 0; i < n; ++ i)
			hsh = hsh * 23 + s[i] - 'a';
		st.insert(hsh);
	}
	if (dep == 20) return ;
	for (int i = 0; i + 1 < n; ++ i) {
		if (s[i] != s[i + 1]) {
			int c = 3 - (s[i] - 'a') - (s[i + 1] - 'a') + 'a';
			int osi = s[i], osi1 = s[i + 1];
			s[i] = s[i + 1] = c;
			solve(dep + 1);
			s[i] = osi; s[i + 1] = osi1;
		}
	}
}

int main() {
	cin >> s; n = strlen(s);
	if (n <= 3) {
		solve();
		cout << st.size() << endl;
		return 0;
	}
	bool ok = 0;
	for (int i = 1; i < n; ++ i) ok |= s[i] != s[0];
	if (!ok) return puts("1"), 0;
	dp[0][0][0][0] = 1;
	dp[0][1][1][0] = 1;
	dp[0][2][2][0] = 1;
	int wanted = 0;
	for (int i = 0; i < n; ++ i)
		(wanted += s[i] - 'a') %= 3;
	for (int i = 1; i < n; ++ i) {
		for (int lst = 0; lst < 3; ++ lst) {
			for (int sum = 0; sum < 3; ++ sum) {
				for (int f = 0; f < 2; ++ f) {
					for (int nw = 0; nw < 3; ++ nw) {
						(dp[i][nw][(sum + nw) % 3][f | (nw == lst)] += dp[i - 1][lst][sum][f]) %= mod;
					}
				}
			}
		}
	}
	bool eql = 1;
	for (int i = 1; i < n; ++ i) eql &= s[i] != s[i - 1];
	int ans = eql;
	for (int lst = 0; lst < 3; ++ lst)
		(ans += dp[n - 1][lst][wanted][1]) %= mod;
	cout << ans << endl;
	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
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 5;
const int mod = 998244353;

int n;
char s[N];
int dp[N][3][3][2];

set <int> st;
void solve(int dep = 0) {
	{
		int hsh = 0;
		for (int i = 0; i < n; ++ i)
			hsh = hsh * 23 + s[i] - 'a';
		st.insert(hsh);
	}
	if (dep == 20) return ;
	for (int i = 0; i + 1 < n; ++ i) {
		if (s[i] != s[i + 1]) {
			int c = 3 - (s[i] - 'a') - (s[i + 1] - 'a') + 'a';
			int osi = s[i], osi1 = s[i + 1];
			s[i] = s[i + 1] = c;
			solve(dep + 1);
			s[i] = osi; s[i + 1] = osi1;
		}
	}
}

int main() {
	cin >> s; n = strlen(s);
	if (n <= 3) {
		solve();
		cout << st.size() << endl;
		return 0;
	}
	bool ok = 0;
	for (int i = 1; i < n; ++ i) ok |= s[i] != s[0];
	if (!ok) return puts("1"), 0;
	dp[0][0][0][0] = 1;
	dp[0][1][1][0] = 1;
	dp[0][2][2][0] = 1;
	int wanted = 0;
	for (int i = 0; i < n; ++ i)
		(wanted += s[i] - 'a') %= 3;
	for (int i = 1; i < n; ++ i) {
		for (int lst = 0; lst < 3; ++ lst) {
			for (int sum = 0; sum < 3; ++ sum) {
				for (int f = 0; f < 2; ++ f) {
					for (int nw = 0; nw < 3; ++ nw) {
						(dp[i][nw][(sum + nw) % 3][f | (nw == lst)] += dp[i - 1][lst][sum][f]) %= mod;
					}
				}
			}
		}
	}
	bool eql = 1;
	for (int i = 1; i < n; ++ i) eql &= s[i] != s[i - 1];
	int ans = eql;
	for (int lst = 0; lst < 3; ++ lst)
		(ans += dp[n - 1][lst][wanted][1]) %= mod;
	cout << ans << endl;
	return 0;
}
```