#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const ll MAX=200005;
const ll MOD=998244353;
char s[MAX];
ll n;
ll dp[MAX][3][3],q,fin,c=1,all=1;
ll make_dp(int x,int m,int e){
    if(x==1){
        if(m==e) return 1;
        return 0;
    }
    if(dp[x][m][e]==-1){
        dp[x][m][e]=0;
        for(int i=0;i<3;i++) if(i!=e){
            dp[x][m][e]+=make_dp(x-1,(m-e+3)%3,i),dp[x][m][e]%=MOD;
        }
    }
    return dp[x][m][e];
}
ll power(ll x,ll y){
    if(y==0) return 1;
    if(y==1) return x;
    ll t=power(x,y/2);
    if(y%2) return ((t*t)%MOD*x)%MOD;
    return (t*t)%MOD;
}
int main(){
    ll t;
    scanf(" %s",s);
    n=strlen(s);
    if(n==2){
        if(s[0]!=s[1]) fin=2;
        else fin=1;
    }
    if(n==3){
        if(s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0]) fin=3;
        else if(s[0]==s[1]&&s[1]==s[2]) fin=1;
        else if(s[0]==s[1]||s[1]==s[2]) fin=6;
        else fin=7;
    }
    else{
    for(int i=0;i<=n+1;i++) for(int j=0;j<3;j++) for(int k=0;k<3;k++) dp[i][j][k]=-1;
    for(int i=0;i<n;i++) q+=s[i]-'a';
    for(int i=0;i<n-1;i++) if(s[i]==s[i+1]) c=0,all++;
    if(all==n){
        fin=1;
    }
    else{
    q%=3;
    fin=power(3,n-1);
    fin-=(make_dp(n,q,0)+make_dp(n,q,1)+make_dp(n,q,2))%MOD,fin+=MOD,fin%=MOD;
    fin+=c,fin%=MOD;
    }
    }
    printf("%lld\n",fin);
}


### 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;
typedef pair<int,int> pii;
typedef long long ll;
const ll MAX=200005;
const ll MOD=998244353;
char s[MAX];
ll n;
ll dp[MAX][3][3],q,fin,c=1,all=1;
ll make_dp(int x,int m,int e){
    if(x==1){
        if(m==e) return 1;
        return 0;
    }
    if(dp[x][m][e]==-1){
        dp[x][m][e]=0;
        for(int i=0;i<3;i++) if(i!=e){
            dp[x][m][e]+=make_dp(x-1,(m-e+3)%3,i),dp[x][m][e]%=MOD;
        }
    }
    return dp[x][m][e];
}
ll power(ll x,ll y){
    if(y==0) return 1;
    if(y==1) return x;
    ll t=power(x,y/2);
    if(y%2) return ((t*t)%MOD*x)%MOD;
    return (t*t)%MOD;
}
int main(){
    ll t;
    scanf(" %s",s);
    n=strlen(s);
    if(n==2){
        if(s[0]!=s[1]) fin=2;
        else fin=1;
    }
    if(n==3){
        if(s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0]) fin=3;
        else if(s[0]==s[1]&&s[1]==s[2]) fin=1;
        else if(s[0]==s[1]||s[1]==s[2]) fin=6;
        else fin=7;
    }
    else{
    for(int i=0;i<=n+1;i++) for(int j=0;j<3;j++) for(int k=0;k<3;k++) dp[i][j][k]=-1;
    for(int i=0;i<n;i++) q+=s[i]-'a';
    for(int i=0;i<n-1;i++) if(s[i]==s[i+1]) c=0,all++;
    if(all==n){
        fin=1;
    }
    else{
    q%=3;
    fin=power(3,n-1);
    fin-=(make_dp(n,q,0)+make_dp(n,q,1)+make_dp(n,q,2))%MOD,fin+=MOD,fin%=MOD;
    fin+=c,fin%=MOD;
    }
    }
    printf("%lld\n",fin);
}


```