#include <cstdio>
#include <cstring>

using namespace std;

char s[200001];
int dp[200001][3][2][4];

int main() {
    int n, m = 998244353, c = 0, ans = 0, i, j, k, l, r;
    
    scanf("%s", s);
    
    n = strlen(s);
    
    for (i = 0; i < n - 1; i++) {
        if (s[i] != s[i + 1]) break;
    }
    
    if (i == n - 1) {
        ans = 1;
    } else if (n == 3) {
        if (s[0] != s[1] && s[1] != s[2] && s[2] != s[0]) {
            ans = 3;
        } else if (s[0] == s[1] || s[1] == s[2]) {
            ans = 6;
        } else {
            ans = 7;
        }
    } else {
        dp[0][0][0][3] = 1;
        
        for (i = 0; i < n; i++) {
            for (j = 0; j < 3; j++) {
                for (k = 0; k < 2; k++) {
                    for (l = 0; l < 4; l++) {
                        if (dp[i][j][k][l] == 0) continue;
                        
                        for (r = 0; r < 3; r++) {
                            int nj = (j + r) % 3, nk = k, nl = r;
                            if (l == r) nk = 1;
                            
                            dp[i + 1][nj][nk][nl] += dp[i][j][k][l];
                            if (dp[i + 1][nj][nk][nl] >= m) dp[i + 1][nj][nk][nl] -= m;
                        }
                    }
                }
            }
        }
        
        for (i = 0; i < n - 1; i++) {
            if (s[i] == s[i + 1]) break;
        }
        
        if (i == n - 1) ans++;
        
        for (i = 0; i < n; i++) c += (s[i] - 'a');
        c %= 3;
        
        for (i = 0; i < 3; i++) {
            ans += dp[n][c][1][i];
            if (ans >= m) ans -= m;
        }
    }
    
    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>

using namespace std;

char s[200001];
int dp[200001][3][2][4];

int main() {
    int n, m = 998244353, c = 0, ans = 0, i, j, k, l, r;
    
    scanf("%s", s);
    
    n = strlen(s);
    
    for (i = 0; i < n - 1; i++) {
        if (s[i] != s[i + 1]) break;
    }
    
    if (i == n - 1) {
        ans = 1;
    } else if (n == 3) {
        if (s[0] != s[1] && s[1] != s[2] && s[2] != s[0]) {
            ans = 3;
        } else if (s[0] == s[1] || s[1] == s[2]) {
            ans = 6;
        } else {
            ans = 7;
        }
    } else {
        dp[0][0][0][3] = 1;
        
        for (i = 0; i < n; i++) {
            for (j = 0; j < 3; j++) {
                for (k = 0; k < 2; k++) {
                    for (l = 0; l < 4; l++) {
                        if (dp[i][j][k][l] == 0) continue;
                        
                        for (r = 0; r < 3; r++) {
                            int nj = (j + r) % 3, nk = k, nl = r;
                            if (l == r) nk = 1;
                            
                            dp[i + 1][nj][nk][nl] += dp[i][j][k][l];
                            if (dp[i + 1][nj][nk][nl] >= m) dp[i + 1][nj][nk][nl] -= m;
                        }
                    }
                }
            }
        }
        
        for (i = 0; i < n - 1; i++) {
            if (s[i] == s[i + 1]) break;
        }
        
        if (i == n - 1) ans++;
        
        for (i = 0; i < n; i++) c += (s[i] - 'a');
        c %= 3;
        
        for (i = 0; i < 3; i++) {
            ans += dp[n][c][1][i];
            if (ans >= m) ans -= m;
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}

```