_, U, D = [input() for _ in range(3)] A = U.count('A') B = U.count('B') a = D.count('A') b = D.count('B') print(min(A, a) + min(B, b))