let R () = stdin.ReadLine() let N, M = let t = R().Split() |> Array.map int in t.[0], t.[1] let S = R().ToCharArray() let T = R().ToCharArray() let toMap = Array.countBy(fun x -> x) >> Map.ofArray let getValue (m:Map) c = match m.TryFind c with | Some(x) -> x | None -> 0 let sMap = S |> toMap let tMap = T |> toMap let aCnt = let s = (sMap, 'A') ||> getValue let t = (tMap, 'A') ||> getValue min s t let bCnt = let s = (sMap, 'B') ||> getValue let t = (tMap, 'B') ||> getValue min s t let ans = aCnt + bCnt ans |> printfn "%i"