#include<bits/stdc++.h>
using namespace std;
const long long MOD=998244353;
long long f[2][3][3][2];
int n,x;
string s;
int main(){
    ios::sync_with_stdio(false);
    cin>>s;
    bool bz=0,bz1=1;
    f[0][0][0][0]=1;
    int sig=0;
    for (int i=0;i<s.size()-1;i++)
        if (s[i]==s[i+1])
            sig++;
    if (sig==s.size()-1&&sig){
        cout<<1;
        return 0;
    }
    for (int i=0;i<s.size();i++,swap(bz,bz1)){
        (x+=s[i]-'a')%=3;
        for (int j=0;j<3;j++)
            for (int k=0;k<3;k++)
                for (int l=0;l<2;l++)
                    if (f[bz][j][k][l]){
                        for (int r=0;r<3;r++)
                            (f[bz1][(j+r)%3][r][l||(k==r&&i)]+=f[bz][j][k][l])%=MOD;
                        f[bz][j][k][l]=0;
                    }   
    }
    long long ans=0;
    for (int i=0;i<3;i++)
        (ans+=f[bz][x][i][1])%=MOD;
    cout<<(ans+(sig==0&&!(s.size()==3&&s[0]!=s[1]&&s[0]!=s[2]&&s[1]!=s[2])))%MOD;
    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>
using namespace std;
const long long MOD=998244353;
long long f[2][3][3][2];
int n,x;
string s;
int main(){
    ios::sync_with_stdio(false);
    cin>>s;
    bool bz=0,bz1=1;
    f[0][0][0][0]=1;
    int sig=0;
    for (int i=0;i<s.size()-1;i++)
        if (s[i]==s[i+1])
            sig++;
    if (sig==s.size()-1&&sig){
        cout<<1;
        return 0;
    }
    for (int i=0;i<s.size();i++,swap(bz,bz1)){
        (x+=s[i]-'a')%=3;
        for (int j=0;j<3;j++)
            for (int k=0;k<3;k++)
                for (int l=0;l<2;l++)
                    if (f[bz][j][k][l]){
                        for (int r=0;r<3;r++)
                            (f[bz1][(j+r)%3][r][l||(k==r&&i)]+=f[bz][j][k][l])%=MOD;
                        f[bz][j][k][l]=0;
                    }   
    }
    long long ans=0;
    for (int i=0;i<3;i++)
        (ans+=f[bz][x][i][1])%=MOD;
    cout<<(ans+(sig==0&&!(s.size()==3&&s[0]!=s[1]&&s[0]!=s[2]&&s[1]!=s[2])))%MOD;
    return 0;
}
```