// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 998244353LL;

int mod3 = 0;
set<string> strs;
string pat = "abc";

/*
void makeStr(string s, int n=6, int mod=0, bool cons=false) {
    if((int)s.length() == n) {
        if(mod == mod3) strs.push_back(s);
        return;
    }
    for(int i=0; i<3; i++) {
        string ns = s + pat[i];
        int nmod = (mod + i) % 3;
        bool ncons = cons | (s.size() && s.back() == pat[i]);
        makeStr(ns, n, nmod, ncons);
    }
}
*/

char convert(char c1, char c2) {
    vector<int> count(3);
    count[ c1 - 'a' ]++;
    count[ c2 - 'a' ]++;

    for(int i=0; i<3; i++) {
        if(count[i] == 0) return (char)('a' + i);
    }
    assert(false);
}

void makeStr(string s) {
    queue<string> que;
    que.push(s);
    strs.insert(s);

    while(que.size()) {
        string cur = que.front(); que.pop();
        for(int i=0; i<(int)cur.size()-1; i++) {
            if(cur[i] == cur[i+1]) continue;
            char c = convert(cur[i], cur[i+1]);
            string nxt = cur;
            nxt[i] = nxt[i+1] = c;

            if(strs.count(nxt)) continue;
            strs.insert(nxt);
            que.push(nxt);
        }
    }
}

int dp[200010][3][3][2];
 
signed main() {
    string s; cin >> s;
    int N = s.length(), origCons = false;
    set<char> vari;
    for(int i=0; i<N; i++) {
        int f = pat.find(s[i]);
        if(i > 0) origCons |= (s[i-1] == s[i]);
        (mod3 += f) %= 3;
        vari.insert(s[i]);
    }

    if(vari.size() == 1) {
        cout << 1 << endl;
    }
    else if(N <= 6) {
        makeStr(s);
        // for(auto x : strs) cout << x << endl;
        cout << strs.size() << endl;
    }
    else {
        dp[1][0][0][0] = dp[1][1][1][0] = dp[1][2][2][0] = 1;
        for(int i=1; i<N; i++) {
            for(int pre=0; pre<3; pre++) {
                for(int mo=0; mo<3; mo++) {
                    for(int cons=0; cons<2; cons++) {
                        for(int k=0; k<3; k++) {
                            int npre = k;
                            int nmo = (mo + k) % 3;
                            int ncons = cons | (pre == k);
                            (dp[i+1][npre][nmo][ncons] += dp[i][pre][mo][cons]) %= MOD;
                        }
                    }
                }
            }
        }

        int ans = !origCons;
        (ans += dp[N][0][mod3][1]) %= MOD;
        (ans += dp[N][1][mod3][1]) %= MOD;
        (ans += dp[N][2][mod3][1]) %= MOD;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 28676