#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;
#define pause system("pause");

const int N = (int)2e5 + 7;
const int inf = (int)1e9 + 7;
int mod = 998244353;

string s;
int n;

ll add(ll a, ll b) {
  return (a + b) % mod;
}

ll mult(ll a, ll b) {
  return a * b % mod;
}

ll sub(ll a, ll b) {
  a -= b;
  if (a < 0) a += mod;
  return a;
}

ll binpow(ll a, int n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = mult(res, a);
    }
    a = mult(a, a);
    n >>= 1;
  }
  return res;
}

int dp[N][3][3];

int main() {
  for (int i = 0; i < 3; i++)
    dp[1][i][i] = 1;

  for (int i = 1; i < N - 1; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        for (int l = 0; l < 3; l++) {
          if (k != l) {
            dp[i + 1][(j + l) % 3][l] = add(dp[i + 1][(j + l) % 3][l], dp[i][j][k]);
          }
        }
      }
    }
  }
  cin >> s;
  n = sz(s);
  set < char > ss;
  for (int i = 0; i < n; i++) {
    ss.insert(s[i]);
  }
  if (sz(ss) == 1) {
    puts("1");
    return 0;
  }
  if (n == 2) {
    cout << 2;
    return 0;
  } else if (n == 3) {
    for (int i = 0; i < 3; i++) {
      ss.insert(s[i]);
    }
    if (sz(ss) == 3) {
      puts("3");
      return 0;
    }
  }
  ll res = binpow(3, n - 1);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += (s[i] - 'a');
  }
  sum %= 3;
  for (int i = 0; i < 3; i++) {
    res = sub(res, dp[n][sum][i]);
  }
  bool fl = 0;
  for (int i = 1; i < n; i++) {
    fl |= (s[i] == s[i - 1]);
  }
  if (!fl)
    res = add(res, 1);
  cout << res << endl;
}

### 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 <bits/stdc++.h>

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;
#define pause system("pause");

const int N = (int)2e5 + 7;
const int inf = (int)1e9 + 7;
int mod = 998244353;

string s;
int n;

ll add(ll a, ll b) {
  return (a + b) % mod;
}

ll mult(ll a, ll b) {
  return a * b % mod;
}

ll sub(ll a, ll b) {
  a -= b;
  if (a < 0) a += mod;
  return a;
}

ll binpow(ll a, int n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = mult(res, a);
    }
    a = mult(a, a);
    n >>= 1;
  }
  return res;
}

int dp[N][3][3];

int main() {
  for (int i = 0; i < 3; i++)
    dp[1][i][i] = 1;

  for (int i = 1; i < N - 1; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        for (int l = 0; l < 3; l++) {
          if (k != l) {
            dp[i + 1][(j + l) % 3][l] = add(dp[i + 1][(j + l) % 3][l], dp[i][j][k]);
          }
        }
      }
    }
  }
  cin >> s;
  n = sz(s);
  set < char > ss;
  for (int i = 0; i < n; i++) {
    ss.insert(s[i]);
  }
  if (sz(ss) == 1) {
    puts("1");
    return 0;
  }
  if (n == 2) {
    cout << 2;
    return 0;
  } else if (n == 3) {
    for (int i = 0; i < 3; i++) {
      ss.insert(s[i]);
    }
    if (sz(ss) == 3) {
      puts("3");
      return 0;
    }
  }
  ll res = binpow(3, n - 1);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += (s[i] - 'a');
  }
  sum %= 3;
  for (int i = 0; i < 3; i++) {
    res = sub(res, dp[n][sum][i]);
  }
  bool fl = 0;
  for (int i = 1; i < n; i++) {
    fl |= (s[i] == s[i - 1]);
  }
  if (!fl)
    res = add(res, 1);
  cout << res << endl;
}

```