#include <bits/stdc++.h>
using namespace std;
#define DEBUG_MODE
#define endl '\n'
#ifdef DEBUG_MODE
#define DEBUG(X) debug_func(X, #X)
#define DEBUG_ENDL endl
#define DEBUG_SEPARATOR_LINE cout<<"=================\n"
#else
#define DEBUG(X) 0
#define DEBUG_ENDL 0
#define DEBUG_SEPARATOR_LINE 0
#endif
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
#define DEBUG_ENDL_S(S) ((S).size() ? "\n" : "")
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
void debug_func_preffix(const string &s) { if(s.size()) cout << s << " = "; }
template <typename T>
void debug_func(const T &t, const string &s = "") {
    debug_func_preffix(s);
    cout << t << DEBUG_ENDL_S(s);
}
template <typename T, typename U>
void debug_func(const P<T, U> &p, const string &s = "") {
    debug_func_preffix(s);
    cout << "(";
    debug_func(p.first);
    cout << ", ";
    debug_func(p.second);
    cout << ")" << DEBUG_ENDL_S(s);
}
template <typename T>
void debug_func(const V<T> &v, const string &s = "") {
    for(ll i = 0; i < v.size(); i++) {
        string t = s + "[" + to_string(i) + "]";
        debug_func(v[i], t);
    }
}

const ll MOD = 998244353;
ll dp[(ll)2e5 + 10][3][3][2];

char change(char a, char b) {
    if(a > b) swap(a, b);
    if(a == 'a' && b == 'b') return 'c';
    if(a == 'a' && b == 'c') return 'b';
    if(a == 'b' && b == 'c') return 'a';
    assert(false);
}

int main() {
    string S;
    cin >> S;
    if(S.size() <= 5) {
        set<string> used = {S};
        queue<string> que;
        que.push(S);
        while(que.size()) {
            string qs = que.front();
            que.pop();
            for(ll i = 0; i < qs.size() - 1; i++) {
                string s = qs;
                if(s[i] == s[i + 1]) continue;
                char c = change(s[i], s[i + 1]);
                s[i] = s[i + 1] = c;
                if(used.find(s) != used.end()) continue;
                que.push(s);
                used.insert(s);
            }
        }
        cout << used.size() << endl;
        return 0;
    }
    ll mod3 = S[0] - 'a';
    for(ll i = 0; i < 3; i++) dp[1][i][i][0] = 1;
    char prec = S[0];
    bool ser = false;
    bool is_same = true;;
    for(ll i = 1; i < S.size(); i++) {
        (mod3 += S[i] - 'a') %= 3;
        if(S[i] == prec) ser = true;
        if(S[i] != prec) is_same = false;
        prec = S[i];
        for(ll m3 = 0; m3 < 3; m3++) {
            for(ll j = 0; j < 3; j++) {
                for(ll k = 0; k < 3; k++) {
                    for(ll l = 0; l < 2; l++) {
                        ll &added = dp[i + 1][(m3 + k) % 3][k][(j != k && !l) ? 0 : 1];
                        (added += dp[i][m3][j][l]) %= MOD;
                    }
                }
            }
        }
    }
    if(is_same) {
        cout << 1 << endl;
        return 0;
    }
    ll ans = 0;
    for(ll i = 0; i < 3; i++) (ans += dp[S.size()][mod3][i][1]) %= MOD;
    (ans += !ser) %= MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 28676