#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

const int MAX_N = 200020;

int dp[2][3][4][MAX_N];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  int n = s.size();
  string t = s;
  t.erase(unique(all(t)), t.end());
  if(t.size() == 1) {
    cout << 1 << endl;
    return 0;
  }

  if(n <= 3) {
    queue<string> que;
    set<string> used;
    que.push(s);
    used.insert(s);
    while(!que.empty()) {
      string u = que.front(); que.pop();
      //cout<<u<<endl;
      rep(i, n-1) {
	if(u[i] != u[i+1]) {
	  char a = u[i], b = u[i+1];
	  if(a > b) swap(a, b);
	  char c;
	  if(a == 'a' && b == 'b') c = 'c';
	  else if(a == 'a' && b == 'c') c = 'b';
	  else if(a == 'b' && b == 'c') c = 'a';
	  string v = u;
	  v[i] = v[i+1] = c;
	  if(!used.count(v)) {
	    used.insert(v);
	    que.push(v);
	  }
	}
      }
    }
    cout << used.size() << endl;
    return 0;
  }

  int ans = n == (int)t.size();
  int MOD = 998244353;
  dp[0][0][3][0] = 1;
  rep(i, n) {
    rep(is_ok, 2) {
      rep(mod_v, 3) {
	rep(prev_c, 4) {
	  rep(add_c, 3) {
	    dp[is_ok||(prev_c==add_c)][(mod_v+add_c)%3][add_c][i+1] += dp[is_ok][mod_v][prev_c][i];
	    dp[is_ok||(prev_c==add_c)][(mod_v+add_c)%3][add_c][i+1] %= MOD;
	  }
	}
      }
    }
  }
  int s_mod = 0;
  rep(i, n) s_mod += (s[i]-'a');
  s_mod %= 3;
  rep(last_c, 3) (ans += dp[1][s_mod][last_c][n]) %= MOD;
  cout << ans << endl;

  return 0;
}

### Prompt

Please provide a cpp coded solution to the problem described below:

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 int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

const int MAX_N = 200020;

int dp[2][3][4][MAX_N];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;
  int n = s.size();
  string t = s;
  t.erase(unique(all(t)), t.end());
  if(t.size() == 1) {
    cout << 1 << endl;
    return 0;
  }

  if(n <= 3) {
    queue<string> que;
    set<string> used;
    que.push(s);
    used.insert(s);
    while(!que.empty()) {
      string u = que.front(); que.pop();
      //cout<<u<<endl;
      rep(i, n-1) {
	if(u[i] != u[i+1]) {
	  char a = u[i], b = u[i+1];
	  if(a > b) swap(a, b);
	  char c;
	  if(a == 'a' && b == 'b') c = 'c';
	  else if(a == 'a' && b == 'c') c = 'b';
	  else if(a == 'b' && b == 'c') c = 'a';
	  string v = u;
	  v[i] = v[i+1] = c;
	  if(!used.count(v)) {
	    used.insert(v);
	    que.push(v);
	  }
	}
      }
    }
    cout << used.size() << endl;
    return 0;
  }

  int ans = n == (int)t.size();
  int MOD = 998244353;
  dp[0][0][3][0] = 1;
  rep(i, n) {
    rep(is_ok, 2) {
      rep(mod_v, 3) {
	rep(prev_c, 4) {
	  rep(add_c, 3) {
	    dp[is_ok||(prev_c==add_c)][(mod_v+add_c)%3][add_c][i+1] += dp[is_ok][mod_v][prev_c][i];
	    dp[is_ok||(prev_c==add_c)][(mod_v+add_c)%3][add_c][i+1] %= MOD;
	  }
	}
      }
    }
  }
  int s_mod = 0;
  rep(i, n) s_mod += (s[i]-'a');
  s_mod %= 3;
  rep(last_c, 3) (ans += dp[1][s_mod][last_c][n]) %= MOD;
  cout << ans << endl;

  return 0;
}

```