#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const ll mod=998244353;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  string s;cin>>s;
  int n=s.size();
  if(n==3){
    if(s[0]==s[1]&&s[1]==s[2])cout<<1<<endl;
    else if(s[0]==s[1]||s[1]==s[2])cout<<6<<endl;
    else if(s[0]==s[2])cout<<7<<endl;
    else cout<<3<<endl;
    return 0;
    }
  
  int b=0,c=0;
  rep(i,n){
    if(s[i]=='a'){b+=2;c+=2;}
    if(s[i]=='b')b++;
    if(s[i]=='c')c++;
    }
  ll ok=1,flag=1;
  rep(i,n-1){
    if(s[i]==s[i+1])flag=0;
    if(s[i]!=s[i+1])ok=0;
    }
  if(ok){
    cout<<1<<endl;
    return 0;
    }
  b%=3;c%=3;
  ll dp[n][3][3][3],dpp[n][3][3][3];
  rep(i,3)rep(j,3)rep(k,3)
    dp[0][i][j][k]=dpp[0][i][j][k]=0;
  dp[0][0][2][2]=dpp[0][0][2][2]=1;
  dp[0][1][1][0]=dpp[0][1][1][0]=1;
  dp[0][2][0][1]=dpp[0][2][0][1]=1;
  rep(i,n-1)rep(j,3)rep(k,3){
    dp[i+1][0][j][k]=(dp[i][0][(j+1)%3][(k+1)%3]+dp[i][1][(j+1)%3][(k+1)%3]+dp[i][2][(j+1)%3][(k+1)%3])%mod;
    dp[i+1][1][j][k]=(dp[i][0][(j+2)%3][k]+dp[i][1][(j+2)%3][k]+dp[i][2][(j+2)%3][k])%mod;
    dp[i+1][2][j][k]=(dp[i][0][j][(k+2)%3]+dp[i][1][j][(k+2)%3]+dp[i][2][j][(k+2)%3])%mod;
    dpp[i+1][0][j][k]=(dpp[i][1][(j+1)%3][(k+1)%3]+dpp[i][2][(j+1)%3][(k+1)%3])%mod;
    dpp[i+1][1][j][k]=(dpp[i][0][(j+2)%3][k]+dpp[i][2][(j+2)%3][k])%mod;
    dpp[i+1][2][j][k]=(dpp[i][0][j][(k+2)%3]+dpp[i][1][j][(k+2)%3])%mod;
    }
  ll ans=flag;
  rep(i,3)ans+=dp[n-1][i][b][c]-dpp[n-1][i][b][c]+mod;
  ans%=mod;
  cout<<ans<<endl;
  return 0;    
  }
### Prompt

Please formulate a CPP solution to 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 <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const ll mod=998244353;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  string s;cin>>s;
  int n=s.size();
  if(n==3){
    if(s[0]==s[1]&&s[1]==s[2])cout<<1<<endl;
    else if(s[0]==s[1]||s[1]==s[2])cout<<6<<endl;
    else if(s[0]==s[2])cout<<7<<endl;
    else cout<<3<<endl;
    return 0;
    }
  
  int b=0,c=0;
  rep(i,n){
    if(s[i]=='a'){b+=2;c+=2;}
    if(s[i]=='b')b++;
    if(s[i]=='c')c++;
    }
  ll ok=1,flag=1;
  rep(i,n-1){
    if(s[i]==s[i+1])flag=0;
    if(s[i]!=s[i+1])ok=0;
    }
  if(ok){
    cout<<1<<endl;
    return 0;
    }
  b%=3;c%=3;
  ll dp[n][3][3][3],dpp[n][3][3][3];
  rep(i,3)rep(j,3)rep(k,3)
    dp[0][i][j][k]=dpp[0][i][j][k]=0;
  dp[0][0][2][2]=dpp[0][0][2][2]=1;
  dp[0][1][1][0]=dpp[0][1][1][0]=1;
  dp[0][2][0][1]=dpp[0][2][0][1]=1;
  rep(i,n-1)rep(j,3)rep(k,3){
    dp[i+1][0][j][k]=(dp[i][0][(j+1)%3][(k+1)%3]+dp[i][1][(j+1)%3][(k+1)%3]+dp[i][2][(j+1)%3][(k+1)%3])%mod;
    dp[i+1][1][j][k]=(dp[i][0][(j+2)%3][k]+dp[i][1][(j+2)%3][k]+dp[i][2][(j+2)%3][k])%mod;
    dp[i+1][2][j][k]=(dp[i][0][j][(k+2)%3]+dp[i][1][j][(k+2)%3]+dp[i][2][j][(k+2)%3])%mod;
    dpp[i+1][0][j][k]=(dpp[i][1][(j+1)%3][(k+1)%3]+dpp[i][2][(j+1)%3][(k+1)%3])%mod;
    dpp[i+1][1][j][k]=(dpp[i][0][(j+2)%3][k]+dpp[i][2][(j+2)%3][k])%mod;
    dpp[i+1][2][j][k]=(dpp[i][0][j][(k+2)%3]+dpp[i][1][j][(k+2)%3])%mod;
    }
  ll ans=flag;
  rep(i,3)ans+=dp[n-1][i][b][c]-dpp[n-1][i][b][c]+mod;
  ans%=mod;
  cout<<ans<<endl;
  return 0;    
  }
```