#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 998244353;

ll dp[2*112345][2][3][3];
int main() {
  string S;cin >> S;
  int N = S.length();
  int Smod3=0;
  bool uni=true;
  bool cont=false;
  repeat(i,N){
    Smod3 = (Smod3+S[i]-'a')%3;
    uni &= S[0]==S[i];
    if(i<N-1) cont|=S[i]==S[i+1];
  }
  if(uni){
    cout << 1 << endl;
    return 0;
  }
  if(N==2){
    cout << (S[0]==S[1]? 1:2)<<endl;
    return 0;
  }
  if(N==3){
    if((S[0]+S[1]+S[2])%3==0){
      cout << 3 << endl;
    }else if(cont){
      cout << 6 << endl;
    }else{
      cout << 7 << endl;
    }
    return 0;
  }
  //cerr << "!!!!!" << endl;
  repeat(i,3){
    dp[0][0][i][i] = 1;
  }
  repeat(i,N-1){
    repeat(t,2){
      repeat(last,3){
        repeat(mod3,3){
          repeat(s,3){
            dp[i+1][t|(last==s)][s][(mod3+s)%3] =
                    (dp[i+1][t|(last==s)][s][(mod3+s)%3]+dp[i][t][last][mod3])%MOD;
            //debug(dp[i+1][t|(last==s)][s][(mod3+s)%3]);
          }
        }
      }
    }
  }
  //debug(cont);
  ll ans = ((dp[N-1][1][0][Smod3]+dp[N-1][1][1][Smod3])%MOD+dp[N-1][1][2][Smod3])%MOD;
  if(!cont) ans = (ans+1)%MOD;
  cout << ans << endl;
  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 <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 998244353;

ll dp[2*112345][2][3][3];
int main() {
  string S;cin >> S;
  int N = S.length();
  int Smod3=0;
  bool uni=true;
  bool cont=false;
  repeat(i,N){
    Smod3 = (Smod3+S[i]-'a')%3;
    uni &= S[0]==S[i];
    if(i<N-1) cont|=S[i]==S[i+1];
  }
  if(uni){
    cout << 1 << endl;
    return 0;
  }
  if(N==2){
    cout << (S[0]==S[1]? 1:2)<<endl;
    return 0;
  }
  if(N==3){
    if((S[0]+S[1]+S[2])%3==0){
      cout << 3 << endl;
    }else if(cont){
      cout << 6 << endl;
    }else{
      cout << 7 << endl;
    }
    return 0;
  }
  //cerr << "!!!!!" << endl;
  repeat(i,3){
    dp[0][0][i][i] = 1;
  }
  repeat(i,N-1){
    repeat(t,2){
      repeat(last,3){
        repeat(mod3,3){
          repeat(s,3){
            dp[i+1][t|(last==s)][s][(mod3+s)%3] =
                    (dp[i+1][t|(last==s)][s][(mod3+s)%3]+dp[i][t][last][mod3])%MOD;
            //debug(dp[i+1][t|(last==s)][s][(mod3+s)%3]);
          }
        }
      }
    }
  }
  //debug(cont);
  ll ans = ((dp[N-1][1][0][Smod3]+dp[N-1][1][1][Smod3])%MOD+dp[N-1][1][2][Smod3])%MOD;
  if(!cont) ans = (ans+1)%MOD;
  cout << ans << endl;
  return 0;
}

```