#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<998244353> mint;
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





string S; int N;
mint dp[201010][3][2][4];
// dp[idx][mod][isvalid][last]
//---------------------------------------------------------------------------------------------------
void partial() {
    set<string> se;
    queue<string> que;

    se.insert(S);
    que.push(S);

    while (!que.empty()) {
        string s = que.front(); que.pop();

        rep(i, 0, N - 1) if (s[i] != s[i + 1]) {
            string ss = s;
            char mi = min(s[i], s[i + 1]);
            char ma = max(s[i], s[i + 1]);

            if (mi == 'a' and ma == 'b') ss[i] = ss[i + 1] = 'c';
            if (mi == 'a' and ma == 'c') ss[i] = ss[i + 1] = 'b';
            if (mi == 'b' and ma == 'c') ss[i] = ss[i + 1] = 'a';

            if (se.count(ss) == 0) {
                se.insert(ss);
                que.push(ss);
            }
        }
    }

    int ans = se.size();
    printf("%d\n", ans);
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S; N = S.length();

    if (N <= 5) {
        partial();
        return;
    }

    int cnt = 0;
    rep(i, 0, N - 1) if (S[i] == S[i + 1]) cnt++;
    if (cnt == N - 1) {
        printf("1\n");
        return;
    }

    dp[0][0][0][3] = 1;
    rep(idx, 0, N) rep(mod, 0, 3) rep(isvalid, 0, 2) rep(last, 0, 4) {
        rep(nxt, 0, 3) {
            int isvalid2 = isvalid;
            if (last == nxt) isvalid2 = 1;
            dp[idx + 1][(mod + nxt) % 3][isvalid2][nxt] += dp[idx][mod][isvalid][last];
        }
    }

    int sm = 0;
    rep(i, 0, N) sm += S[i] - 'a';
    sm %= 3;

    mint ans = 0;
    rep(last, 0, 3) ans += dp[N][sm][1][last];
    if (cnt == 0) ans += 1;
    cout << ans << endl;

}

Measured memory_bytes: 19664