#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 998244353

int n;
string s;
map<string,bool> vis;
ll res=0;
ll dp[200010][3][3][2];

void dfs(string t){
  res++;
  vis[t]=true;
  rep(i,n-1){
    if(t[i]==t[i+1])continue;
    string nxt=t;
    repl(c,'a','c'+1){
      if(c!=t[i]&&c!=t[i+1])nxt[i]=nxt[i+1]=c;
    }
    if(!vis[nxt])dfs(nxt);
  }
}

int main(){
  cin>>s;
  n=s.size();
  bool same=true;
  rep(i,n-1){
    if(s[i]!=s[i+1])same=false;
  }
  if(same){
    cout<<1<<endl;
    return 0;
  }
  if(n<=3){
    dfs(s);
  }else{
    rep(i,3)dp[1][i][i][0]=1;
    repl(i,1,n)rep(j,3)rep(k,3)rep(l,2){
      rep(nxt,3){
        (dp[i+1][(j+nxt)%3][nxt][l||(nxt==k)]+=dp[i][j][k][l])%=mod;
      }
    }
    ll v=0;
    bool f=false;
    rep(i,n){
      v+=s[i]-'a';
      if(i<n-1&&s[i]==s[i+1])f|=1;
    }
    v%=3;
    rep(i,3)(res+=dp[n][v][i][1])%=mod;
    res+=(!f);
  }
  cout<<res%mod<<endl;
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

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 unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 998244353

int n;
string s;
map<string,bool> vis;
ll res=0;
ll dp[200010][3][3][2];

void dfs(string t){
  res++;
  vis[t]=true;
  rep(i,n-1){
    if(t[i]==t[i+1])continue;
    string nxt=t;
    repl(c,'a','c'+1){
      if(c!=t[i]&&c!=t[i+1])nxt[i]=nxt[i+1]=c;
    }
    if(!vis[nxt])dfs(nxt);
  }
}

int main(){
  cin>>s;
  n=s.size();
  bool same=true;
  rep(i,n-1){
    if(s[i]!=s[i+1])same=false;
  }
  if(same){
    cout<<1<<endl;
    return 0;
  }
  if(n<=3){
    dfs(s);
  }else{
    rep(i,3)dp[1][i][i][0]=1;
    repl(i,1,n)rep(j,3)rep(k,3)rep(l,2){
      rep(nxt,3){
        (dp[i+1][(j+nxt)%3][nxt][l||(nxt==k)]+=dp[i][j][k][l])%=mod;
      }
    }
    ll v=0;
    bool f=false;
    rep(i,n){
      v+=s[i]-'a';
      if(i<n-1&&s[i]==s[i+1])f|=1;
    }
    v%=3;
    rep(i,3)(res+=dp[n][v][i][1])%=mod;
    res+=(!f);
  }
  cout<<res%mod<<endl;
  return 0;
}

```