_ = input() U = input() D = input() Ua = U.count('A') Ub = U.count('B') Da = D.count('A') Db = D.count('B') print(min(Ua, Da) + min(Ub, Db))