#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int maxn = 200100;
const ll base = 998244353;

int n;
ll f[maxn][4][4];

int main() {
     //freopen("in.txt","r",stdin);
      ios_base::sync_with_stdio(0); cin.tie(0);
      string t;
      cin>>t;
      n = t.size();
      if (n==1) {
          cout<<1<<endl;
          return 0;
      }
      if (n==3) {
          int tt=0;
          for (int i=0;i<n;i++) tt |= 1<<(t[i]-'a');
//cout<<"fuck "<<tt<<endl;
          if (tt==7) {
              cout<<3<<endl;
              return 0;
          }
      }
      bool ok=true;
      for (int i=0;i<n-1;i++) ok &= (t[i]==t[i+1]);
      if (ok) {
          cout<<1<<endl;
          return 0;
      }
      for (int i=0;i<3;i++) f[1][i][i] = 1ll;
      for (int i=1;i<n;i++)
        for (int s=0;s<3;s++)
          for (int x=0;x<3;x++)
            for (int y=0;y<3;y++){
                if (x==y) continue;
                int s1 = (s+y)%3;
                f[i+1][y][s1] = (f[i+1][y][s1] + f[i][x][s])%base;
            }
      ll res=1;
      for (int i=1;i<n;i++) res= (res*3)%base;
      int s=0;
      for (int i=0;i<n;i++) s = (s + (t[i]-'a'))%3;
      for (int i=0;i<3;i++) {
          res = (res - f[n][i][s] + base) % base;
      }
      ok=true;
      for (int i=0;i<n-1;i++) ok &= (t[i]!=t[i+1]);
      if (ok) res = (res+1)%base;
      cout<<res<<endl;
}


### 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>
#define ll long long

using namespace std;

const int maxn = 200100;
const ll base = 998244353;

int n;
ll f[maxn][4][4];

int main() {
     //freopen("in.txt","r",stdin);
      ios_base::sync_with_stdio(0); cin.tie(0);
      string t;
      cin>>t;
      n = t.size();
      if (n==1) {
          cout<<1<<endl;
          return 0;
      }
      if (n==3) {
          int tt=0;
          for (int i=0;i<n;i++) tt |= 1<<(t[i]-'a');
//cout<<"fuck "<<tt<<endl;
          if (tt==7) {
              cout<<3<<endl;
              return 0;
          }
      }
      bool ok=true;
      for (int i=0;i<n-1;i++) ok &= (t[i]==t[i+1]);
      if (ok) {
          cout<<1<<endl;
          return 0;
      }
      for (int i=0;i<3;i++) f[1][i][i] = 1ll;
      for (int i=1;i<n;i++)
        for (int s=0;s<3;s++)
          for (int x=0;x<3;x++)
            for (int y=0;y<3;y++){
                if (x==y) continue;
                int s1 = (s+y)%3;
                f[i+1][y][s1] = (f[i+1][y][s1] + f[i][x][s])%base;
            }
      ll res=1;
      for (int i=1;i<n;i++) res= (res*3)%base;
      int s=0;
      for (int i=0;i<n;i++) s = (s + (t[i]-'a'))%3;
      for (int i=0;i<3;i++) {
          res = (res - f[n][i][s] + base) % base;
      }
      ok=true;
      for (int i=0;i<n-1;i++) ok &= (t[i]!=t[i+1]);
      if (ok) res = (res+1)%base;
      cout<<res<<endl;
}


```