#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e5+100,mod=998244353;
ll dp[N][3];
ll pd[N][3][3];
int32_t main(){
    sync;
    string s;
    cin >> s;
    ll n=s.size();
    ll a=0,b=0,c=0;
    for (int i=0;i<n;i++){
        if (s[i]=='a') a++;
        if (s[i]=='b') b++;
        if (s[i]=='c') c++;
    }
    if (a==n || b==n || c==n) kill(1);

    if (n==3){
        if (a==1 && b==c){
            kill(3);
        }
        if (s[0]==s[2] && s[1]!=s[0]) kill(7);
        kill(6);
    }
    dp[0][0]=1;
    for (int i=0;i<n;i++){
        for (int j=0;j<3;j++){
            for (int k=0;k<3;k++){
                ll z=(k+j)%3;
                dp[i+1][z]+=dp[i][j];
                dp[i+1][z]%=mod;
            }
        }
    }
    ll z=0*a+1*b+2*c;
    ll ans=dp[n][z%3];
    pd[1][0][0]=1;
    pd[1][1][1]=1;
    pd[1][2][2]=1;
    for (int i=1;i<n;i++){
        for (int j=0;j<3;j++){
            for (int k=0;k<3;k++){
                for (int p=0;p<3;p++){
                    if (p==k) continue;
                    ll z=j+p;
                    z%=3;
                    pd[i+1][z][p]+=pd[i][j][k];
                    pd[i+1][z][p]%=mod;
                }
            }
        }
    }
    for (int i=0;i<3;i++)
        ans-=pd[n][z%3][i];
    ans+=4*mod;
    ll p1=1;
    for (int i=0;i<n-1;i++){
        if (s[i]==s[i+1]) p1=0;
    }
    cout << (ans+p1)%mod;





}
/*abbbabbabbababababbbcccccbbcbcbccbcbccaccacacacaccacabbabacacabba*/

### Prompt

Please provide a cpp coded solution 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>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define endl '\n'
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define kill(x) return cout<<x<<'\n', 0;
using namespace std;
const int N=2e5+100,mod=998244353;
ll dp[N][3];
ll pd[N][3][3];
int32_t main(){
    sync;
    string s;
    cin >> s;
    ll n=s.size();
    ll a=0,b=0,c=0;
    for (int i=0;i<n;i++){
        if (s[i]=='a') a++;
        if (s[i]=='b') b++;
        if (s[i]=='c') c++;
    }
    if (a==n || b==n || c==n) kill(1);

    if (n==3){
        if (a==1 && b==c){
            kill(3);
        }
        if (s[0]==s[2] && s[1]!=s[0]) kill(7);
        kill(6);
    }
    dp[0][0]=1;
    for (int i=0;i<n;i++){
        for (int j=0;j<3;j++){
            for (int k=0;k<3;k++){
                ll z=(k+j)%3;
                dp[i+1][z]+=dp[i][j];
                dp[i+1][z]%=mod;
            }
        }
    }
    ll z=0*a+1*b+2*c;
    ll ans=dp[n][z%3];
    pd[1][0][0]=1;
    pd[1][1][1]=1;
    pd[1][2][2]=1;
    for (int i=1;i<n;i++){
        for (int j=0;j<3;j++){
            for (int k=0;k<3;k++){
                for (int p=0;p<3;p++){
                    if (p==k) continue;
                    ll z=j+p;
                    z%=3;
                    pd[i+1][z][p]+=pd[i][j][k];
                    pd[i+1][z][p]%=mod;
                }
            }
        }
    }
    for (int i=0;i<3;i++)
        ans-=pd[n][z%3][i];
    ans+=4*mod;
    ll p1=1;
    for (int i=0;i<n-1;i++){
        if (s[i]==s[i+1]) p1=0;
    }
    cout << (ans+p1)%mod;





}
/*abbbabbabbababababbbcccccbbcbcbccbcbccaccacacacaccacabbabacacabba*/

```