from collections import Counter input() S = Counter(list(input())) T = Counter(list(input())) print(min(S['A'], T['A']) + min(S['B'], T['B']))