N, M, S, T = open(0).read().split() SA = S.count("A") SB = int(N) - SA TA = T.count("A") TB = int(M) - TA print(min(SA, TA) + min(SB, TB))