#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char s[252521];
ll dp[252521][2][3][3];

int main(){
  scanf("%s",s);
  n = strlen(s);
  bool alla = false;
  alla = alla || (count(s,s+n,'a')==n);
  alla = alla || (count(s,s+n,'b')==n);
  alla = alla || (count(s,s+n,'c')==n);
  if(alla){
    puts("1");
    return 0;
  }
  if(n==3){
    int cnta = count(s,s+n,'a');
    int cntb = count(s,s+n,'b');
    int cntc = count(s,s+n,'c');
    if(cnta==1 && cntb==1 && cntc==1){
      puts("3");
    }else if(s[0]==s[1] || s[1]==s[2]){
      puts("6");
    }else{
      puts("7");
    }
    return 0;
  }
  dp[1][0][0][0] = dp[1][0][1][1] = dp[1][0][2][2] = 1;
  FOR(i,1,n)REP(ok,2)REP(m,3)REP(bef,3){
    REP(u,3){
      int nm = (m+u)%3;
      int nok = ok || (bef==u);
      (dp[i+1][nok][nm][u] += dp[i][ok][m][bef]) %= MOD;
    }
  }
  int md = 0;
  REP(i,n)md = (md + (s[i]-'a')) % 3;
  int ok = false;
  REP(i,n-1)ok = ok || (s[i]==s[i+1]);
  ll ans = 0;
  REP(i,3)ans += dp[n][1][md][i];
  if(!ok)ans++;
  ans %= MOD;
  printf("%lld\n",ans);
  return 0;
}

### Prompt

Generate 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 <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char s[252521];
ll dp[252521][2][3][3];

int main(){
  scanf("%s",s);
  n = strlen(s);
  bool alla = false;
  alla = alla || (count(s,s+n,'a')==n);
  alla = alla || (count(s,s+n,'b')==n);
  alla = alla || (count(s,s+n,'c')==n);
  if(alla){
    puts("1");
    return 0;
  }
  if(n==3){
    int cnta = count(s,s+n,'a');
    int cntb = count(s,s+n,'b');
    int cntc = count(s,s+n,'c');
    if(cnta==1 && cntb==1 && cntc==1){
      puts("3");
    }else if(s[0]==s[1] || s[1]==s[2]){
      puts("6");
    }else{
      puts("7");
    }
    return 0;
  }
  dp[1][0][0][0] = dp[1][0][1][1] = dp[1][0][2][2] = 1;
  FOR(i,1,n)REP(ok,2)REP(m,3)REP(bef,3){
    REP(u,3){
      int nm = (m+u)%3;
      int nok = ok || (bef==u);
      (dp[i+1][nok][nm][u] += dp[i][ok][m][bef]) %= MOD;
    }
  }
  int md = 0;
  REP(i,n)md = (md + (s[i]-'a')) % 3;
  int ok = false;
  REP(i,n-1)ok = ok || (s[i]==s[i+1]);
  ll ans = 0;
  REP(i,3)ans += dp[n][1][md][i];
  if(!ok)ans++;
  ans %= MOD;
  printf("%lld\n",ans);
  return 0;
}

```