_ = map(int, input().split()) S, T = input(), input() print(min(S.count("A"), T.count("A")) + min(S.count("B"), T.count("B")))