defmodule Main do defp count(str, x) do str |> String.graphemes |> Enum.count(&(&1 == x)) end def main do [_, _] = IO.gets("") |> String.trim |> String.split |> Enum.map(&String.to_integer/1) s = IO.gets("") |> String.trim t = IO.gets("") |> String.trim ans = min(count(s, "A"), count(t, "A")) + min(count(s, "B"), count(t, "B")) IO.puts ans end end