program normalization
  implicit none
  integer(8), parameter :: md = 998244353_8
  integer :: n, x, i, j, k, l
  integer(8) :: dp(200000,0:2,0:2), m
  character(200000) :: s
  logical :: ll, ny
  dp = 0_8
  read(*,*) s
  s = trim(adjustl(s))
  n = len_trim(s)
  x = ichar(s(n:n))-97
  ll = .true.
  ny = .false.
  do i = 1, n-1
    if (s(i:i).ne.s(i+1:i+1)) then
      ll = .false.
    else
      ny = .true.
    end if
    x = x+ichar(s(i:i))-97
  end do
  x = mod(x,3)
  if (ll) then
    write(*,'(i0)') 1
    stop
  end if
  if (n.eq.2) then
    write(*,'(i0)') 2
    stop
  end if
  if ((n.eq.3).and.(.not.ny).and.(s(1:1).ne.s(3:3))) then
    write(*,'(i0)') 3
    stop
  end if
  dp(1,0,0) = 1_8
  dp(1,1,1) = 1_8
  dp(1,2,2) = 1_8
  do i = 1, n-1
    do j = 0, 2
      do k = 0, 2
        do l = 0, 2
          if (l.eq.k) cycle
          dp(i+1,mod(j+l,3),l) = mod(dp(i+1,mod(j+l,3),l)+dp(i,j,k),md)
        end do
      end do
    end do
  end do
  m = 1_8
  do i = 1, n-1
    m = mod(3_8*m,md)
  end do
  if (.not.ny) m = m+1_8
  m = m+md-mod(sum(dp(n,x,0:2)),md)
  write(*,'(i0)') mod(m,md)
  stop
end program normalization