#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void 
debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}
template<lint mod>
struct Int_{
  unsigned x;
  unsigned mpow(Int_ a,unsigned k){
    Int_ res=1;
    while(k){
      if(k&1) res=res*a;
      a=a*a;
      k>>=1;
    }
    return res.x;
  }
  unsigned inverse(Int_ a){
    return mpow(a,mod-2);
  }
  Int_(): x(0) { }
  Int_(long long sig) {
    int sigt=sig%mod;
    if(sigt<0) sigt+=mod;
    x=sigt;
  }
  unsigned get() const { return (unsigned)x; }
  
  Int_ &operator+=(Int_ that) { if((x += that.x) >= mod) x -= mod; return *this; }
  Int_ &operator-=(Int_ that) { if((x += mod - that.x) >= mod) x -= mod; return *this; }
  Int_ &operator*=(Int_ that) { x = (unsigned long long)x * that.x % mod; return *this; }
  Int_ &operator=(Int_ that) { x=that.x; return *this;}
  Int_ &operator/=(Int_ that) { x=(unsigned long long) x * inverse(that.x)%mod; return *this;}
  bool operator==(Int_ that) const { return x==that.x; }
  bool operator!=(Int_ that) const { return x!=that.x; }

  Int_ operator-() const { return Int_(0)-Int_(*this);}
  Int_ operator+(Int_ that) const { return Int_(*this) += that; }
  Int_ operator-(Int_ that) const { return Int_(*this) -= that; }
  Int_ operator*(Int_ that) const { return Int_(*this) *= that; }
  Int_ operator/(Int_ that) const { return Int_(*this) /= that; }
  Int_ inv(){
    return Int_(mpow(x,mod-2));
  }
};

namespace std{
  template<lint mod>
  ostream &operator <<(ostream& out,const Int_<mod>& a){
    out<<a.get();
    return out;
  }
  template<lint mod>
  istream &operator >>(istream& in,Int_<mod>& a){
    in>>a.x;
    return in;
  }
};

typedef Int_<998244353> Int;

Int mpow(Int a,lint k){
  Int res=1;
  while(k){
    if(k&1) res=res*a;
    a=a*a;
    k>>=1;
  }
  return res;
}
//const int INF=5e8;
char S[200005];
Int dp[2][2][3][3];//dp[cur/nxt][already consecutive][parity][lastone]
int n;
int brute(){
  typedef vector<int> vi;
  set<vi> SS;
  vi in(n);
  REP(i,n) in[i]=S[i]-'a';
  queue<vi> q;q.push(in);SS.insert(in);
  while(!q.empty()){
    vi cur=q.front();q.pop();
    REP(i,n-1) if(cur[i]!=cur[i+1]){
      vi nxt=cur;
      int trg=cur[i]+cur[i+1];
      if(trg&1) trg=(trg+3)/2;
      else trg/=2;
      trg%=3;
      nxt[i]=nxt[i+1]=trg;
      if(!SS.count(nxt)){
        SS.insert(nxt);
        q.push(nxt);
      }
    }
  }
  return SS.size();
}
int main(){
  scanf("%s",S);
  n=strlen(S);
  if(n<=5){
    cout<<brute()<<endl;
    return 0;
  }

  int cur=0,nxt=1;
  REP(i,3) dp[cur][0][i][i]=1;
  for(int i=1;i<n;++i){
    REP(t,2) REP(p,3) REP(l,3) if(dp[cur][t][p][l].x){
      REP(j,3){
        dp[nxt][t|(l==j?1:0)][(p+j)%3][j]+=dp[cur][t][p][l];
      }
    }
    swap(cur,nxt);
    CLR(dp[nxt]);
  }
  int p=0;
  REP(i,n) p+=S[i]-'a';
  int conc=0,dif=0;
  REP(i,n-1){
    if(S[i]==S[i+1]) conc=1;
    else dif=1;
  }
  if(dif==0){
    puts("1");
    return 0;
  }
  p%=3;
  Int res=0;
  REP(l,3){
    res+=dp[cur][1][p][l];
  }
  if(!conc) res+=1;
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 384