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

const int MAXN = 2e5 + 5;
const int MOD = 998244353;

int N;
char s[MAXN];
int dp[MAXN][3][3];

void load() {
	scanf("%s", s);
}

inline int add(int x, int y) {
	x += y;
	if (x >= MOD)	
		x -= MOD;
	else if (x < 0)
		x += MOD;
	return x;
}

inline int mul(int x, int y) {
	return (long long)x * y % MOD;
}

int solve() {
	N = strlen(s);
	
	int cnt = 0;
	for (int i = 1; i < N; i++)
		cnt += s[i] == s[i - 1];
	
	if (cnt == N - 1)
		return 1;
	
	if (N == 3 && !cnt && s[0] != s[2])
		return 3;
		
	for (int i = 0; i < 3; i++)
		dp[0][i][i] = 1;
		
	for (int i = 1; i < N; i++) 
		for (int j = 0; j < 3; j++)
			for (int k = 0; k < 3; k++)
				for (int l = 0; l < 3; l++)
					if (l != k)
						dp[i][j][k] = add(dp[i][j][k], dp[i - 1][(j - k + 3) % 3][l]);
	
	int pot = 1;
	for (int i = 1; i < N; i++)
		pot = mul(pot, 3);
	
	int sum = 0;
	for (int i = 0; i < N; i++)
		sum += s[i] - 'a';
	
	int sol = !cnt + pot;
	for (int i = 0; i < 3; i++)
		sol = add(sol, -dp[N - 1][sum % 3][i]);
	
	return sol;
}

int main() {
	load();
	printf("%d\n", solve());
	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;

const int MAXN = 2e5 + 5;
const int MOD = 998244353;

int N;
char s[MAXN];
int dp[MAXN][3][3];

void load() {
	scanf("%s", s);
}

inline int add(int x, int y) {
	x += y;
	if (x >= MOD)	
		x -= MOD;
	else if (x < 0)
		x += MOD;
	return x;
}

inline int mul(int x, int y) {
	return (long long)x * y % MOD;
}

int solve() {
	N = strlen(s);
	
	int cnt = 0;
	for (int i = 1; i < N; i++)
		cnt += s[i] == s[i - 1];
	
	if (cnt == N - 1)
		return 1;
	
	if (N == 3 && !cnt && s[0] != s[2])
		return 3;
		
	for (int i = 0; i < 3; i++)
		dp[0][i][i] = 1;
		
	for (int i = 1; i < N; i++) 
		for (int j = 0; j < 3; j++)
			for (int k = 0; k < 3; k++)
				for (int l = 0; l < 3; l++)
					if (l != k)
						dp[i][j][k] = add(dp[i][j][k], dp[i - 1][(j - k + 3) % 3][l]);
	
	int pot = 1;
	for (int i = 1; i < N; i++)
		pot = mul(pot, 3);
	
	int sum = 0;
	for (int i = 0; i < N; i++)
		sum += s[i] - 'a';
	
	int sol = !cnt + pot;
	for (int i = 0; i < 3; i++)
		sol = add(sol, -dp[N - 1][sum % 3][i]);
	
	return sol;
}

int main() {
	load();
	printf("%d\n", solve());
	return 0;
}
```