#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll dp[200001][3] = {};
ll dp2[200001][3][3] = {};
int main() {
	string s; cin >> s;
	int len = s.length();
	if (len <= 4) {
		int out = 1;
		queue<string> q;
		map<string, int> mp;
		mp[s] = 1;
		q.push(s);
		while (!q.empty()) {
			string x = q.front(); q.pop();
			rep(i, len - 1) {
				string y = x;
				if (x[i] != x[i + 1]) {
					char u = ('d' - x[i]) + 'a' - x[i + 1] + 'a';
					y[i] = y[i + 1] = u;
					if (!mp[y]) {
						mp[y] = 1; q.push(y); out++;
					}
				}
			}
		}
		cout << out << endl;
	}
	else {
		bool f = true; int chk = 0;
		bool g = true;
		rep(i, len - 1) {
			if (s[i] != s[i + 1])f = false;
			if (s[i] == s[i + 1])g = false;
			chk = (chk + (int)(s[i] - 'a')) % 3;
		}
		chk = (chk + (int)(s[len - 1] - 'a')) % 3;
		if (f) {
			cout << 1 << endl;
		}
		else {
			dp[0][0] = 1;
			dp2[0][0][0] = 1;
			dp2[1][0][0] = 1;
			rep(i, len) {
				rep(j, 3) {
					rep(k, 3) {
						dp[i + 1][(k + j) % 3] = (dp[i + 1][(k + j) % 3] + dp[i][j]) % MOD;
						if (j != k) {
							rep(l, 3) {
								dp2[i + 1][k][(k + l) % 3] = (dp2[i + 1][k][(k + l) % 3] + dp2[i][j][l]) % MOD;
							}
						}
					}
				}
			}
			ll sum = 0;
			rep(i, 3) {
				sum += dp2[len][i][chk];
			}
			sum %= MOD;
			ll res = dp[len][chk] - sum;
			if (g)res++;
			res = (res + 2 * MOD) % MOD;
			cout << res << endl;
		}
	}
	return 0;
}
### Prompt

Please provide a CPP coded solution 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<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
ll dp[200001][3] = {};
ll dp2[200001][3][3] = {};
int main() {
	string s; cin >> s;
	int len = s.length();
	if (len <= 4) {
		int out = 1;
		queue<string> q;
		map<string, int> mp;
		mp[s] = 1;
		q.push(s);
		while (!q.empty()) {
			string x = q.front(); q.pop();
			rep(i, len - 1) {
				string y = x;
				if (x[i] != x[i + 1]) {
					char u = ('d' - x[i]) + 'a' - x[i + 1] + 'a';
					y[i] = y[i + 1] = u;
					if (!mp[y]) {
						mp[y] = 1; q.push(y); out++;
					}
				}
			}
		}
		cout << out << endl;
	}
	else {
		bool f = true; int chk = 0;
		bool g = true;
		rep(i, len - 1) {
			if (s[i] != s[i + 1])f = false;
			if (s[i] == s[i + 1])g = false;
			chk = (chk + (int)(s[i] - 'a')) % 3;
		}
		chk = (chk + (int)(s[len - 1] - 'a')) % 3;
		if (f) {
			cout << 1 << endl;
		}
		else {
			dp[0][0] = 1;
			dp2[0][0][0] = 1;
			dp2[1][0][0] = 1;
			rep(i, len) {
				rep(j, 3) {
					rep(k, 3) {
						dp[i + 1][(k + j) % 3] = (dp[i + 1][(k + j) % 3] + dp[i][j]) % MOD;
						if (j != k) {
							rep(l, 3) {
								dp2[i + 1][k][(k + l) % 3] = (dp2[i + 1][k][(k + l) % 3] + dp2[i][j][l]) % MOD;
							}
						}
					}
				}
			}
			ll sum = 0;
			rep(i, 3) {
				sum += dp2[len][i][chk];
			}
			sum %= MOD;
			ll res = dp[len][chk] - sum;
			if (g)res++;
			res = (res + 2 * MOD) % MOD;
			cout << res << endl;
		}
	}
	return 0;
}
```