#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 998244353;
int O = 332748118;
int dp[300000][3];
signed main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    int sz = s.size();
    dp[0][0] = 1, dp[0][1] = 1, dp[0][2] = 1;
    for (int i=1; i < sz; i++){
        dp[i][0] = (dp[i-1][1] + dp[i-1][2]) % MOD;
        dp[i][1] = (dp[i-1][0] + dp[i-1][2]) % MOD;
        dp[i][2] = (dp[i-1][1] + dp[i-1][0]) % MOD;
    }
    int x = (dp[sz-1][0] + dp[sz-1][1] + dp[sz-1][2]) % MOD;
    int S = 1;
    for (int i=0; i < sz; i++){
        S *= 3;
        S %= MOD;
    }
    S -= x;
    S %= MOD;
    if (S < 0) S += MOD;
    S *= O;
    S %= MOD;
    bool df = true;
    for (int i=0; i < s.size() - 1; i++){
        if (s[i] != s[i+1]) df = false;
    }
    if (df){
        cout << 1 << endl;
        return 0;
    }
    bool eq = false;
    for (int i=0; i < s.size() - 1; i++){
        if (s[i] == s[i+1]) eq = true;
    }
    if (sz % 3 != 0){
        cout << (S+!eq) % MOD << endl;
        return 0;
    }
    else{
        int A = sz/3 - 1, num = 1;
        while (A > 0){
            A--;
            num *= 2;
            num %= MOD;
        }
        int aa = 0, bb = 0, cc=0;
        for (int i=0; i < s.size(); i++){
            if (s[i] == 'a') aa++;
            if (s[i] == 'b') bb++;
            if (s[i] == 'c') cc++;
        }
        bool good = true;
        if (aa%3==0 && bb % 3==0 && cc%3==0) good = false;
        if (aa%3!=0 && bb % 3!=0 && cc%3!=0) good = false;
        if (good){
            cout << (S+!eq+num) % MOD << endl;
        }
        else{
            if (sz == 3){
                cout << 3 << endl;
                return 0;
            }
            S -= 2*num;
            S %= MOD;
            if (S<0) S += MOD;
            cout << (S+!eq) % MOD << endl;
        }
    }
    return 0;
}

### Prompt

Create a solution in Cpp for 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>
#define int long long
using namespace std;
int MOD = 998244353;
int O = 332748118;
int dp[300000][3];
signed main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin >> s;
    int sz = s.size();
    dp[0][0] = 1, dp[0][1] = 1, dp[0][2] = 1;
    for (int i=1; i < sz; i++){
        dp[i][0] = (dp[i-1][1] + dp[i-1][2]) % MOD;
        dp[i][1] = (dp[i-1][0] + dp[i-1][2]) % MOD;
        dp[i][2] = (dp[i-1][1] + dp[i-1][0]) % MOD;
    }
    int x = (dp[sz-1][0] + dp[sz-1][1] + dp[sz-1][2]) % MOD;
    int S = 1;
    for (int i=0; i < sz; i++){
        S *= 3;
        S %= MOD;
    }
    S -= x;
    S %= MOD;
    if (S < 0) S += MOD;
    S *= O;
    S %= MOD;
    bool df = true;
    for (int i=0; i < s.size() - 1; i++){
        if (s[i] != s[i+1]) df = false;
    }
    if (df){
        cout << 1 << endl;
        return 0;
    }
    bool eq = false;
    for (int i=0; i < s.size() - 1; i++){
        if (s[i] == s[i+1]) eq = true;
    }
    if (sz % 3 != 0){
        cout << (S+!eq) % MOD << endl;
        return 0;
    }
    else{
        int A = sz/3 - 1, num = 1;
        while (A > 0){
            A--;
            num *= 2;
            num %= MOD;
        }
        int aa = 0, bb = 0, cc=0;
        for (int i=0; i < s.size(); i++){
            if (s[i] == 'a') aa++;
            if (s[i] == 'b') bb++;
            if (s[i] == 'c') cc++;
        }
        bool good = true;
        if (aa%3==0 && bb % 3==0 && cc%3==0) good = false;
        if (aa%3!=0 && bb % 3!=0 && cc%3!=0) good = false;
        if (good){
            cout << (S+!eq+num) % MOD << endl;
        }
        else{
            if (sz == 3){
                cout << 3 << endl;
                return 0;
            }
            S -= 2*num;
            S %= MOD;
            if (S<0) S += MOD;
            cout << (S+!eq) % MOD << endl;
        }
    }
    return 0;
}

```