#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
#define sz(x)       int(x.size())
//#define int         long long

using namespace std;

typedef pair<int, int> pii;
const int N = int(2e5 + 2);
const int mod = (int)998244353;

string s;
int n, sum, f[N][3][3][2], ok;

void add(int& x, int y) {if((x += y) >= mod) x -= mod;}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> s; n = sz(s); s = ' ' + s; ok = 0; sum = s[1] - 'a';
    for(int i = 2; i <= n; ++i) ok += (s[i] != s[i - 1]), sum += s[i] - 'a';
    if(!ok) return cout << 1, 0;
    if(n == 2) return cout << 2, 0;
    if(n == 3) {
        if(s[1] != s[2] && s[2] != s[3] && s[3] != s[1]) return cout << 3, 0;
        else if(s[1] == s[3]) return cout << 7, 0;
        return cout << 6, 0;
    }
    for(int i = 0; i < 3; ++i) f[1][i][i][0] = 1;
    auto combine = [&](int x, int y) {if((x += y) >= 3) x -= 3; return x;};
    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 < 2; ++l) {
                    int& cur = f[i][j][k][l];
                    if(cur == 0) continue;
                    for(int x = 0; x < 3; ++x)
                        add(f[i + 1][combine(j, x)][x][l | (k == x)], cur);
                }
            }
        }
    }
    int res = (ok == n - 1); sum %= 3;
    for(int i = 0; i < 3; ++i) add(res, f[n][sum][i][1]);
    cout << res;
}

### Prompt

Develop a solution in Cpp 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>
#define pb          emplace_back
#define ll          long long
#define fi          first
#define se          second
#define mp          make_pair
#define sz(x)       int(x.size())
//#define int         long long

using namespace std;

typedef pair<int, int> pii;
const int N = int(2e5 + 2);
const int mod = (int)998244353;

string s;
int n, sum, f[N][3][3][2], ok;

void add(int& x, int y) {if((x += y) >= mod) x -= mod;}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> s; n = sz(s); s = ' ' + s; ok = 0; sum = s[1] - 'a';
    for(int i = 2; i <= n; ++i) ok += (s[i] != s[i - 1]), sum += s[i] - 'a';
    if(!ok) return cout << 1, 0;
    if(n == 2) return cout << 2, 0;
    if(n == 3) {
        if(s[1] != s[2] && s[2] != s[3] && s[3] != s[1]) return cout << 3, 0;
        else if(s[1] == s[3]) return cout << 7, 0;
        return cout << 6, 0;
    }
    for(int i = 0; i < 3; ++i) f[1][i][i][0] = 1;
    auto combine = [&](int x, int y) {if((x += y) >= 3) x -= 3; return x;};
    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 < 2; ++l) {
                    int& cur = f[i][j][k][l];
                    if(cur == 0) continue;
                    for(int x = 0; x < 3; ++x)
                        add(f[i + 1][combine(j, x)][x][l | (k == x)], cur);
                }
            }
        }
    }
    int res = (ok == n - 1); sum %= 3;
    for(int i = 0; i < 3; ++i) add(res, f[n][sum][i][1]);
    cout << res;
}

```