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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 998244353;
const int MN = 200010;

ll dp[MN][2][3][3];

int main() {
	string s;
	cin >> s;
	int n = s.size();

	bool one = 1;
	rep(i, n-1) if (s[i] != s[i+1]) one = 0;

	if (one) {
		cout << "1\n";
		return 0;
	}

	if (n >= 4) {
		rep(i, 3) dp[1][0][i][i] = 1;

		for (int i = 2; i <= n; ++i) {
			rep(f, 2) {
				rep(j, 3) {
					rep(la, 3) {
						if (dp[i-1][f][la] == 0) continue;
						rep(k, 3) {
							dp[i][f | (la == k)][(j+k)%3][k] += dp[i-1][f][j][la];
							dp[i][f | (la == k)][(j+k)%3][k] %= MOD;
						}
					}
				}
			}
		}

		int m = 0;
		rep(i, n) {
			m = (m + s[i]) % 3;
		}

		ll ret = (dp[n][1][m][0] + dp[n][1][m][1] + dp[n][1][m][2]) % MOD;
		bool f = 0;
		rep(i, n-1) f |= (s[i] == s[i+1]);
		if (!f) ret = (ret + 1) % MOD;
		cout << ret << endl;
	} else {
		set<string> vis;

		queue<string> que;
		que.push(s);

		while (!que.empty()) {
			string t = que.front(); que.pop();
			if (vis.count(t)) continue;
			vis.insert(t);

			rep(i, n-1) {
				if (t[i] != t[i+1]) {
					string nx = t;
					for (char c = 'a'; c <= 'c'; ++c) {
						if (c != t[i] && c != t[i+1]) {
							nx[i] = nx[i+1] = c;
							if (!vis.count(nx)) {
								que.push(nx);
							}
						}
					}
				}
			}
		}
		cout << vis.size() << endl;
	}

	return 0;
}
### Prompt

In CPP, your task is to solve 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>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 998244353;
const int MN = 200010;

ll dp[MN][2][3][3];

int main() {
	string s;
	cin >> s;
	int n = s.size();

	bool one = 1;
	rep(i, n-1) if (s[i] != s[i+1]) one = 0;

	if (one) {
		cout << "1\n";
		return 0;
	}

	if (n >= 4) {
		rep(i, 3) dp[1][0][i][i] = 1;

		for (int i = 2; i <= n; ++i) {
			rep(f, 2) {
				rep(j, 3) {
					rep(la, 3) {
						if (dp[i-1][f][la] == 0) continue;
						rep(k, 3) {
							dp[i][f | (la == k)][(j+k)%3][k] += dp[i-1][f][j][la];
							dp[i][f | (la == k)][(j+k)%3][k] %= MOD;
						}
					}
				}
			}
		}

		int m = 0;
		rep(i, n) {
			m = (m + s[i]) % 3;
		}

		ll ret = (dp[n][1][m][0] + dp[n][1][m][1] + dp[n][1][m][2]) % MOD;
		bool f = 0;
		rep(i, n-1) f |= (s[i] == s[i+1]);
		if (!f) ret = (ret + 1) % MOD;
		cout << ret << endl;
	} else {
		set<string> vis;

		queue<string> que;
		que.push(s);

		while (!que.empty()) {
			string t = que.front(); que.pop();
			if (vis.count(t)) continue;
			vis.insert(t);

			rep(i, n-1) {
				if (t[i] != t[i+1]) {
					string nx = t;
					for (char c = 'a'; c <= 'c'; ++c) {
						if (c != t[i] && c != t[i+1]) {
							nx[i] = nx[i+1] = c;
							if (!vis.count(nx)) {
								que.push(nx);
							}
						}
					}
				}
			}
		}
		cout << vis.size() << endl;
	}

	return 0;
}
```