#include <cstdio>
#include <cstring>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

const int N = 200010;
const int mod = 998244353;

char s[N];
int n, fl, ans, tmp;
int vis[N], f[N][3], h[N][3][3];

void brute_force()
{
    int tmp = 0;
    FOR(i, 1, n) tmp = tmp * 10 + s[i] - 'a' + 1;
    if (vis[tmp]) return; else ++ans, vis[tmp] = 1;

    FOR(i, 1, n - 1) if (s[i] != s[i + 1])
    {
        char t1 = s[i], t2 = s[i + 1], t3 = 'a' + 'b' + 'c' - t1 - t2;
        s[i] = s[i + 1] = t3; brute_force();
        s[i] = t1, s[i + 1] = t2;
    }
}

int main()
{
    scanf("%s", s + 1); n = strlen(s + 1);

    FOR(i, 2, n) if (s[i] != s[1]) fl = 1;
    if (!fl) {puts("1"); return 0;}

    if (n <= 3) {brute_force(); printf("%d\n", ans); return 0;}

    FOR(i, 2, n) if (s[i] == s[i - 1]) fl = 0;
    if (fl) ans = 1;

    FOR(i, 1, n) tmp += s[i] - 'a'; tmp %= 3;

    f[0][0] = 1;
    FOR(i, 0, n - 1) FOR(j, 0, 2) FOR(k, 0, 2)
        (f[i + 1][(j + k) % 3] += f[i][j]) %= mod;
    (ans += f[n][tmp]) %= mod;

    FOR(i, 0, 2) h[1][i][i] = 1;
    FOR(i, 1, n - 1) FOR(j, 0, 2) FOR(k, 0, 2) FOR(l, 0, 2)
        if (l != k) (h[i + 1][(j + l) % 3][l] += h[i][j][k]) %= mod;
    FOR(i, 0, 2) (ans += mod - h[n][tmp][i]) %= mod;

    printf("%d\n", ans);

    return 0;
}

### Prompt

Please create a solution in CPP 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 <cstdio>
#include <cstring>
#define FOR(i, l, r) for(int i = l; i <= r; ++i)

using namespace std;

const int N = 200010;
const int mod = 998244353;

char s[N];
int n, fl, ans, tmp;
int vis[N], f[N][3], h[N][3][3];

void brute_force()
{
    int tmp = 0;
    FOR(i, 1, n) tmp = tmp * 10 + s[i] - 'a' + 1;
    if (vis[tmp]) return; else ++ans, vis[tmp] = 1;

    FOR(i, 1, n - 1) if (s[i] != s[i + 1])
    {
        char t1 = s[i], t2 = s[i + 1], t3 = 'a' + 'b' + 'c' - t1 - t2;
        s[i] = s[i + 1] = t3; brute_force();
        s[i] = t1, s[i + 1] = t2;
    }
}

int main()
{
    scanf("%s", s + 1); n = strlen(s + 1);

    FOR(i, 2, n) if (s[i] != s[1]) fl = 1;
    if (!fl) {puts("1"); return 0;}

    if (n <= 3) {brute_force(); printf("%d\n", ans); return 0;}

    FOR(i, 2, n) if (s[i] == s[i - 1]) fl = 0;
    if (fl) ans = 1;

    FOR(i, 1, n) tmp += s[i] - 'a'; tmp %= 3;

    f[0][0] = 1;
    FOR(i, 0, n - 1) FOR(j, 0, 2) FOR(k, 0, 2)
        (f[i + 1][(j + k) % 3] += f[i][j]) %= mod;
    (ans += f[n][tmp]) %= mod;

    FOR(i, 0, 2) h[1][i][i] = 1;
    FOR(i, 1, n - 1) FOR(j, 0, 2) FOR(k, 0, 2) FOR(l, 0, 2)
        if (l != k) (h[i + 1][(j + l) % 3][l] += h[i][j][k]) %= mod;
    FOR(i, 0, 2) (ans += mod - h[n][tmp][i]) %= mod;

    printf("%d\n", ans);

    return 0;
}

```