integer(16) N
integer(16),allocatable,dimension(:)::RX,RY,BX,BY
logical,allocatable,dimension(:)::sold
integer cnt
integer(16) i,j

read*,N
allocate(RX(N),RY(N),BX(N),BY(N))
do i=1,N
  read*,RX(i),RY(i)
end do
do i=1,N
  read*,BX(i),BY(i)
end do
call HeapsortPair(N,BX,BY)
call HeaPsortPair(N,RY,RX)

allocate(sold(N))
sold=.False.
cnt=0
do i=1,N
  do j=N,1,-1
    if(sold(j))cycle
    if(RX(j)<BX(i).and.RY(j)<BY(j))then
      sold(j)=.true.
      cnt=cnt+1
      exit
    endif
  end do
end do

print"(i0)",cnt

contains

subroutine HeapsortPair(n,array,array2)
  implicit none
!ここの入力は状況に応じて変更すること
  integer(16),intent(in) :: n
  integer(16),intent(inout) :: array(1:n),array2(1:n)
  integer(16)::i,k,j,l
  integer(16):: t,t2

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
        t2=array2(L)
     else
        t=array(k)
        t2=array2(k)
        array(k)=array(1)
        array2(k)=array2(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           array2(1)=t2
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           array2(i)=array2(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
     array2(i)=t2
  enddo
  return
end subroutine HeapsortPair
end