open System let countAB str = str |> Seq.toList |> List.partition (fun c -> c = 'A') |> fun (aLst, bLst) -> (List.length aLst, List.length bLst) let solve s t = let a1, b1 = countAB s let a2, b2 = countAB t Math.Min(a1, a2) + Math.Min(b1, b2) let () = Console.ReadLine() |> ignore let s = Console.ReadLine() let t = Console.ReadLine() solve s t |> printfn "%d"