#include<bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
 
const int maxn = 2e5 + 5;
const int INF = 998244353;
 
int n, ans = 0;
int dp[maxn][3][3][2];
string s;
map<string, int> vis;
 
inline void dfs(string str){
	if(vis[str])
		return;
	vis[str] = true;
	++ans;
	FOR(i, 0, 2) if(str[i] != str[i + 1]){
		string t = str;
		if(t[i] == 'a' && t[i + 1] == 'b' || t[i + 1] == 'a' && t[i] == 'b')
			t[i] = t[i + 1] = 'c';
		else if(t[i] == 'a' && t[i + 1] == 'c' || t[i + 1] == 'a' && t[i] == 'c')
			t[i] = t[i + 1] = 'b';
		else if(t[i] == 'b' && t[i + 1] == 'c' || t[i + 1] == 'b' && t[i] == 'c')
			t[i] = t[i + 1] = 'a';
		dfs(t);
	}
	return;
}
 
int main(){
	cin >> s;
	n = s.size();
	if(n == 2)
		putchar('1' + (s[0] != s[1]));
	else if(n == 3){
		dfs(s);
		cout << ans << endl;
	}
	else{
		int sum = 0;
		bool f1 = false, f2 = true;
		FOR(i, 0, n){
			if(i != n - 1)
                            f1 |= (s[i] != s[i + 1]), f2 &= (s[i] != s[i + 1]);
			(sum += s[i] - 'a') %= 3;
		}
		if(!f1)
			puts("1");
		else{
			FOR(k, 0, 3)
				dp[0][k][k][0] = 1;
			FOR(i, 0, n - 1) FOR(j, 0, 3) FOR(k, 0, 3) FOR(l, 0, 2) if(dp[i][j][k][l]) FOR(k_, 0, 3)
				(dp[i + 1][(j + k_) % 3][k_][l || (k == k_)] += dp[i][j][k][l]) %= INF;
			FOR(k, 0, 3)
				(ans += dp[n - 1][sum][k][1]) %= INF;
			(ans += f2) %= INF;
			cout << ans << 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<bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define MP make_pair
#define PB push_back
#define PH push
#define fst first
#define snd second
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
 
const int maxn = 2e5 + 5;
const int INF = 998244353;
 
int n, ans = 0;
int dp[maxn][3][3][2];
string s;
map<string, int> vis;
 
inline void dfs(string str){
	if(vis[str])
		return;
	vis[str] = true;
	++ans;
	FOR(i, 0, 2) if(str[i] != str[i + 1]){
		string t = str;
		if(t[i] == 'a' && t[i + 1] == 'b' || t[i + 1] == 'a' && t[i] == 'b')
			t[i] = t[i + 1] = 'c';
		else if(t[i] == 'a' && t[i + 1] == 'c' || t[i + 1] == 'a' && t[i] == 'c')
			t[i] = t[i + 1] = 'b';
		else if(t[i] == 'b' && t[i + 1] == 'c' || t[i + 1] == 'b' && t[i] == 'c')
			t[i] = t[i + 1] = 'a';
		dfs(t);
	}
	return;
}
 
int main(){
	cin >> s;
	n = s.size();
	if(n == 2)
		putchar('1' + (s[0] != s[1]));
	else if(n == 3){
		dfs(s);
		cout << ans << endl;
	}
	else{
		int sum = 0;
		bool f1 = false, f2 = true;
		FOR(i, 0, n){
			if(i != n - 1)
                            f1 |= (s[i] != s[i + 1]), f2 &= (s[i] != s[i + 1]);
			(sum += s[i] - 'a') %= 3;
		}
		if(!f1)
			puts("1");
		else{
			FOR(k, 0, 3)
				dp[0][k][k][0] = 1;
			FOR(i, 0, n - 1) FOR(j, 0, 3) FOR(k, 0, 3) FOR(l, 0, 2) if(dp[i][j][k][l]) FOR(k_, 0, 3)
				(dp[i + 1][(j + k_) % 3][k_][l || (k == k_)] += dp[i][j][k][l]) %= INF;
			FOR(k, 0, 3)
				(ans += dp[n - 1][sum][k][1]) %= INF;
			(ans += f2) %= INF;
			cout << ans << endl;
		}
	}
	return 0;
}
```