input() s = input() t = input() A = s.count('A') B = s.count('B') a = t.count('A') b = t.count('B') print(min(A, a) + min(B, b))