module S = Set.Make (struct type t = string let compare = compare end) ;;

Scanf.scanf "%s" (fun s ->
    let n = String.length s in
    let replace s i a b =
        let c = char_of_int (294 - int_of_char a - int_of_char b) in
        String.init n (fun j -> if j = i || j = i + 1 then c else s.[j])
    in
    let rec dfs s set =
        let rec loop i set =
            if i = n - 1 then set else
            if s.[i] = s.[i + 1] then loop (i + 1) set else (
                let s2 = replace s i s.[i] s.[i + 1] in
                let set = if S.mem s2 set then set else dfs s2 (S.add s2 set) in
                loop (i + 1) set
            )
        in
        loop 0 set
    in
    let streak s =
        let rec loop i =
            if i = n - 1 then true else
                if s.[i] = s.[i + 1] then loop (i + 1) else false
        in
        loop 0
    in
    let nondup s =
        let rec loop i =
            if i = n - 1 then 1 else
                if s.[i] = s.[i + 1] then 0 else loop (i + 1)
        in
        loop 0
    in
    let sum s =
        let rec loop i acc =
            if i = n then acc else loop (i + 1) (acc + int_of_char s.[i] - 97)
        in
        loop 0 0
    in

    let m = 998244353 in
    let ( +@) a b = (a + b) mod m in
    let ( -@) a b = (((a - b) mod m) + m) mod m in
    let ( *@) a b = (a * b) mod m in

    let pow a b =
        let rec loop r b acc =
            if b = 0 then acc else
                loop (r *@ r) (b lsr 1) (if b land 1 = 0 then acc else acc *@ r)
        in
        loop a b 1
    in
    let solve s =
        let adjust v =
            if n mod 3 <> 0 then v else (
                if sum s mod 3 = 0 then v -@ pow 2 (n / 3) else v +@ pow 2 (n / 3 - 1)
            )
        in
        let rec loop i dp1 dp2 =
            if i = n then adjust dp1 else
                loop (i + 1) (dp1 *@ 3 +@ dp2) (dp2 *@ 2)
        in
        if streak s then 1 else loop 1 0 1 +@ nondup s
    in
    Printf.printf "%d\n" @@ if n <= 3 then S.cardinal (dfs s (S.singleton s)) else solve s
)