#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
char a[1000005];
int dp[1000005][3][3];
const int modo=998244353;
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    scanf("%s",a);
    int n=strlen(a);
    int i;
    for (i=1;i<n;i++)
    {
        if (a[i]==a[i-1])
        {
            break;
        }
    }
    int ans=0;
    if (i==n)
    {
        ans++;
    }
    for (i=1;i<n;i++)
    {
        if (a[i]!=a[i-1])
        {
            break;
        }
    }
    if (i==n)
    {
        puts("1");
        return 0;
    }
    int cnt=0;
    for (i=0;i<n;i++)
    {
        cnt+=((a[i]-'a')%3);
        cnt%=3;
    }
    if (n==3)
    {
        int i,j;
        for (i=0;i<3;i++)
        {
            for (j=i+1;j<3;j++)
            {
                if (a[i]==a[j]) break;
            }
            if (j!=3) break;
        }
        if (i==3)
        {
            puts("3");
            return 0;
        }
    }
    dp[1][0][0]=1;
    dp[1][1][1]=1;
    dp[1][2][2]=1;
    for (i=1;i<=n;i++)
    {
        int j,k;
        for (j=0;j<3;j++)
        {
            for (k=0;k<3;k++)
            {
                int l;
                for (l=0;l<3;l++)
                {
                    if (k==l) continue;
                    dp[i+1][(j+k)%3][k]+=dp[i][j][l];
                    dp[i+1][(j+k)%3][k]%=modo;
                }
            }
        }
    }
    int p=1;
    for (i=1;i<n;i++)
    {
        p=(long long)p*3%modo;
    }
    ans+=p;
    ans%=modo;
    for (i=0;i<3;i++)
    {
        ans-=dp[n][cnt][i];
        ans%=modo;
    }
    ans+=modo;
    ans%=modo;
    printf("%d\n",ans);
    return 0;
}

### Prompt

Please formulate 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<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
char a[1000005];
int dp[1000005][3][3];
const int modo=998244353;
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    scanf("%s",a);
    int n=strlen(a);
    int i;
    for (i=1;i<n;i++)
    {
        if (a[i]==a[i-1])
        {
            break;
        }
    }
    int ans=0;
    if (i==n)
    {
        ans++;
    }
    for (i=1;i<n;i++)
    {
        if (a[i]!=a[i-1])
        {
            break;
        }
    }
    if (i==n)
    {
        puts("1");
        return 0;
    }
    int cnt=0;
    for (i=0;i<n;i++)
    {
        cnt+=((a[i]-'a')%3);
        cnt%=3;
    }
    if (n==3)
    {
        int i,j;
        for (i=0;i<3;i++)
        {
            for (j=i+1;j<3;j++)
            {
                if (a[i]==a[j]) break;
            }
            if (j!=3) break;
        }
        if (i==3)
        {
            puts("3");
            return 0;
        }
    }
    dp[1][0][0]=1;
    dp[1][1][1]=1;
    dp[1][2][2]=1;
    for (i=1;i<=n;i++)
    {
        int j,k;
        for (j=0;j<3;j++)
        {
            for (k=0;k<3;k++)
            {
                int l;
                for (l=0;l<3;l++)
                {
                    if (k==l) continue;
                    dp[i+1][(j+k)%3][k]+=dp[i][j][l];
                    dp[i+1][(j+k)%3][k]%=modo;
                }
            }
        }
    }
    int p=1;
    for (i=1;i<n;i++)
    {
        p=(long long)p*3%modo;
    }
    ans+=p;
    ans%=modo;
    for (i=0;i<3;i++)
    {
        ans-=dp[n][cnt][i];
        ans%=modo;
    }
    ans+=modo;
    ans%=modo;
    printf("%d\n",ans);
    return 0;
}

```