#include <iostream>
#include <string>
using namespace std;

string S; long long dp[200009][3][4], power[200009], mod = 998244353;

void init() {
	dp[0][0][3] = 1;
	for (int i = 0; i < 200000; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 4; k++) {
				for (int l = 0; l < 3; l++) {
					if (k != l) {
						dp[i + 1][(j + l) % 3][l] += dp[i][j][k];
						dp[i + 1][(j + l) % 3][l] %= mod;
					}
				}
			}
		}
	}
	power[0] = 1; for (int i = 1; i <= 200000; i++) power[i] = (power[i - 1] * 3LL) % mod;
}

int main() {
	cin >> S; init();
	if (S == "abc" || S == "acb" || S == "bac" || S == "bca" || S == "cab" || S == "cba") {
		cout << "3" << endl;
		return 0;
	}
	bool flag1 = false, flag2 = false; int cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		cnt += (S[i] - 'a');
		if (i < S.size() - 1) {
			if (S[i] == S[i + 1]) flag1 = true;
			if (S[i] != S[i + 1]) flag2 = true;
		}
	}
	long long sum = dp[S.size()][cnt % 3][0] + dp[S.size()][cnt % 3][1] + dp[S.size()][cnt % 3][2]; sum %= mod;
	if (flag2 == false) cout << "1" << endl;
	else if (flag1 == false) {
		cout << (power[S.size() - 1] - sum + mod + 1) % mod << endl;
	}
	else {
		cout << (power[S.size() - 1] - sum + mod) % mod << 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 <iostream>
#include <string>
using namespace std;

string S; long long dp[200009][3][4], power[200009], mod = 998244353;

void init() {
	dp[0][0][3] = 1;
	for (int i = 0; i < 200000; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 4; k++) {
				for (int l = 0; l < 3; l++) {
					if (k != l) {
						dp[i + 1][(j + l) % 3][l] += dp[i][j][k];
						dp[i + 1][(j + l) % 3][l] %= mod;
					}
				}
			}
		}
	}
	power[0] = 1; for (int i = 1; i <= 200000; i++) power[i] = (power[i - 1] * 3LL) % mod;
}

int main() {
	cin >> S; init();
	if (S == "abc" || S == "acb" || S == "bac" || S == "bca" || S == "cab" || S == "cba") {
		cout << "3" << endl;
		return 0;
	}
	bool flag1 = false, flag2 = false; int cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		cnt += (S[i] - 'a');
		if (i < S.size() - 1) {
			if (S[i] == S[i + 1]) flag1 = true;
			if (S[i] != S[i + 1]) flag2 = true;
		}
	}
	long long sum = dp[S.size()][cnt % 3][0] + dp[S.size()][cnt % 3][1] + dp[S.size()][cnt % 3][2]; sum %= mod;
	if (flag2 == false) cout << "1" << endl;
	else if (flag1 == false) {
		cout << (power[S.size() - 1] - sum + mod + 1) % mod << endl;
	}
	else {
		cout << (power[S.size() - 1] - sum + mod) % mod << endl;
	}
	return 0;
}
```