let countAB str = let len_str = String.length str in let str_lst = Array.init len_str (fun i -> str.[i]) |> Array.to_list in List.partition (fun c -> c = 'A') str_lst |> fun (aLst, bLst) -> (List.length aLst, List.length bLst) let solve s t = let a1, b1 = countAB s and a2, b2 = countAB t in (min a1 a2) + (min b1 b2) let () = let _ = read_line () and s = read_line () and t = read_line () in solve s t |> Printf.printf "%d\n"