output_description: Print the number of strings that can be possibly obtained by repeatedly
  performing the operation, modulo 998244353.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
attempt: def main():
      md = 998244353
      s = input()
      n = len(s)
      al = True  # allすべて同じ文字
      an = 1  # any連続が存在すると0
      for c0, c1 in zip(s, s[1:]):
          if c0 == c1:
              an = 0
          else:
              al = False
          if an == 0 and not al:
              break
      if al:
          print(1)
          exit()
      if n == 2:
          print(2)
          exit()
      if n == 3:
          if s[0] == s[-1]:
              print(7)
          elif s[0] == s[1] or s[1] == s[2]:
              print(6)
          else:
              print(3)
          exit()
      # print(n)
      # print(an)
      ord0 = ord("a")
      r = sum(ord(c) - ord0 for c in s) % 3
      if n % 3 == 0:
          d = pow(2, n // 3 - 1, md)
          if r == 0:
              an -= d * 2
          else:
              an += d
      print((pow(3, n - 1, md) - pow(2, n - 1, md) + an) % md)
  
  
  main()
  
problem_description: Statement
  
  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`).
samples: [{"input": "abc", "output": "3\n    \n\n`abc`, `aaa` and `ccc` can be obtained.\n\n* * *"}, {"input": "abbac", "output": "65\n    \n\n* * *"}, {"input": "babacabac", "output": "6310\n    \n\n* * *"}, {"input": "ababacbcacbacacbcbbcbbacbaccacbacbacba", "output": "148010497"}]