import Control.Applicative ((<$>), (<*>)) import Data.List (sort) main :: IO () main = solve <$> f <*> f >>= print where f = getLine >> map read <$> words <$> getLine solve :: [Int] -> [Int] -> Int solve ws bs = let ws' = sort ws bs' = sort bs in max (f 0 0 ws' bs') (f 0 0 bs' ws') where f ht wt xs ys = let xs' = dropWhile (<= wt) xs in case xs' of (n:ns) -> f (ht+1) n ys ns [] -> ht