let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let ab = Array.to_list @@ Array.init n @@ fun _ -> Scanf.sscanf (read_line ()) "%d %d" @@ fun a b -> (a, b)
let cd = Array.to_list @@ Array.init n @@ fun _ -> Scanf.sscanf (read_line ()) "%d %d" @@ fun c d -> (c, d)

let rec loop ans reds = function
  | [] -> ans
  | (c, d) :: bs ->
      let ts = List.filter (fun (a, b)-> a < c && b < d) reds in
      if List.length ts > 0 then
        let red = ts |> List.sort compare |> List.rev |> List.hd in
        loop (ans + 1) (List.filter ((<>) red) reds) bs
      else 
        loop ans reds bs

let () = Printf.printf "%d\n" @@ loop 0 ab (cd |> List.sort compare |> List.rev)