//ARC094-D F - Normalization

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

const int MOD = 998244353;
long long dp[210000][4][4][3]; // (mod 3, last, already)

void add (long long &a, long long b);
long long solve(const string &S);

signed main () {
    string S; 
    cin >> S;

    cout << solve(S) << '\n';

    return (0);
}

void add (long long &a, long long b) {
    a += b;
    if (a >= MOD) {
        a -= MOD;
    }

    return ;
}

long long solve(const string &S) {
    set<char> se;
    bool exist_ren = false;
    long long smod = 0;

    for (int i=0 ;i<S.size() ;i++) {
        se.insert(S[i]);
        smod = (smod + (S[i] - 'a')) % 3;

        if (i+1 < S.size() && S[i] == S[i+1]) {
            exist_ren = true;
        }
    }

    if (se.size() == 1) return 1;
    else if (S.size() == 2) return 2;
    else if (S.size() == 3) {
        if (se.size() == 3) return 3;
        else if (S[0] == S[2]) return 7;
        else return 6;
    }

    memset(dp, 0, sizeof(dp));
    
    for (int last=0 ;last<3 ;last++ ) {
        dp[1][last][last][0] = 1;
    }
    for (int i=1 ;i<S.size() ;i++ ) {
        for (int sum=0 ;sum<3 ;sum++ ) {
            for (int last=0; last<3 ;last++ ) {
                for (int last2=0 ;last2<3 ;last2++ ) {
                    add(dp[i+1][(sum+last2)%3][last2][1], dp[i][sum][last][1]);
                    add(dp[i+1][(sum+last2)%3][last2][last==last2], dp[i][sum][last][0]);
                }
            }
        }
    }
    
    long long res = (exist_ren ? 0 : 1);
    for (int last=0 ;last<3 ;last++ ) {
        add(res, dp[S.size()][smod][last][1]);
    }

    return (res);
}

### Prompt

Construct a CPP code solution to the problem outlined:

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
//ARC094-D F - Normalization

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

const int MOD = 998244353;
long long dp[210000][4][4][3]; // (mod 3, last, already)

void add (long long &a, long long b);
long long solve(const string &S);

signed main () {
    string S; 
    cin >> S;

    cout << solve(S) << '\n';

    return (0);
}

void add (long long &a, long long b) {
    a += b;
    if (a >= MOD) {
        a -= MOD;
    }

    return ;
}

long long solve(const string &S) {
    set<char> se;
    bool exist_ren = false;
    long long smod = 0;

    for (int i=0 ;i<S.size() ;i++) {
        se.insert(S[i]);
        smod = (smod + (S[i] - 'a')) % 3;

        if (i+1 < S.size() && S[i] == S[i+1]) {
            exist_ren = true;
        }
    }

    if (se.size() == 1) return 1;
    else if (S.size() == 2) return 2;
    else if (S.size() == 3) {
        if (se.size() == 3) return 3;
        else if (S[0] == S[2]) return 7;
        else return 6;
    }

    memset(dp, 0, sizeof(dp));
    
    for (int last=0 ;last<3 ;last++ ) {
        dp[1][last][last][0] = 1;
    }
    for (int i=1 ;i<S.size() ;i++ ) {
        for (int sum=0 ;sum<3 ;sum++ ) {
            for (int last=0; last<3 ;last++ ) {
                for (int last2=0 ;last2<3 ;last2++ ) {
                    add(dp[i+1][(sum+last2)%3][last2][1], dp[i][sum][last][1]);
                    add(dp[i+1][(sum+last2)%3][last2][last==last2], dp[i][sum][last][0]);
                }
            }
        }
    }
    
    long long res = (exist_ren ? 0 : 1);
    for (int last=0 ;last<3 ;last++ ) {
        add(res, dp[S.size()][smod][last][1]);
    }

    return (res);
}

```