#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 998244353;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

string S;
int N;
ll dp[200009][2][3][3];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>S;
    N=S.size();
    
    if(N<=7){
        set<string> T,R;
        T.insert(S);
        while(T.size()){
            set<string> U;
            for(auto t:T){
                R.insert(t);
                rep(i,N-1){
                    if(t[i]!=t[i+1]){
                        string a=t;
                        a[i]=a[i+1]='a'+'b'+'c'-a[i]-a[i+1];
                        if(R.count(a)==0){
                            U.insert(a);
                            R.insert(a);
                        }
                    }
                }
            }
            T=U;
        }
        cout1(R.size())
        return 0;
    }
    
    int cnt[3]={};
    int tot=0;
    rep(i,N){
        int c=S[i]-'a';
        cnt[c]++;
        tot+=c;
    }
    
    rep(i,3)if(cnt[i]==N){
        cout1(1)
        return 0;
    }
    
    dp[1][0][0][0]=1;
    dp[1][0][1][1]=1;
    dp[1][0][2][2]=1;
    FOR(i,1,N){
        rep(j,2)rep(x,3)rep(y,3)rep(z,3){
            (dp[i+1][j|(x==z)][z][(y+z)%3]+=dp[i][j][x][y])%=MOD;
        }
    }
    
    ll ret=1;
    rep(i,3) ret+=dp[N][1][i][tot%3];
    rep(i,N-1)if(S[i]==S[i+1]){
        ret--;
        break;
    }
    cout1(ret%MOD)
}
### 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"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 998244353;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

string S;
int N;
ll dp[200009][2][3][3];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>S;
    N=S.size();
    
    if(N<=7){
        set<string> T,R;
        T.insert(S);
        while(T.size()){
            set<string> U;
            for(auto t:T){
                R.insert(t);
                rep(i,N-1){
                    if(t[i]!=t[i+1]){
                        string a=t;
                        a[i]=a[i+1]='a'+'b'+'c'-a[i]-a[i+1];
                        if(R.count(a)==0){
                            U.insert(a);
                            R.insert(a);
                        }
                    }
                }
            }
            T=U;
        }
        cout1(R.size())
        return 0;
    }
    
    int cnt[3]={};
    int tot=0;
    rep(i,N){
        int c=S[i]-'a';
        cnt[c]++;
        tot+=c;
    }
    
    rep(i,3)if(cnt[i]==N){
        cout1(1)
        return 0;
    }
    
    dp[1][0][0][0]=1;
    dp[1][0][1][1]=1;
    dp[1][0][2][2]=1;
    FOR(i,1,N){
        rep(j,2)rep(x,3)rep(y,3)rep(z,3){
            (dp[i+1][j|(x==z)][z][(y+z)%3]+=dp[i][j][x][y])%=MOD;
        }
    }
    
    ll ret=1;
    rep(i,3) ret+=dp[N][1][i][tot%3];
    rep(i,N-1)if(S[i]==S[i+1]){
        ret--;
        break;
    }
    cout1(ret%MOD)
}
```