import Data.List import qualified Data.Map as Map f ::[(Char,Int)]->[(Char,Int)] f c@(('A',_):('B',_):[])=c f (('A',a):[])=(('A',a):('B',0):[]) f (('B',b):[])=(('A',0):('B',b):[]) main =do t<-getLine u<-getLine l<-getLine let xs=group $ sort u ys=group $ sort l zs1=f $ zip (map head xs) (map length xs) zs2=f $ zip (map head ys) (map length ys) ms=Map.fromListWith min (zs1++zs2) print $ sum(Map.elems ms)