program answer
  implicit none
  integer(8) :: i, HH, WW, M, ans, c, d, k, nn, n
  integer(8), allocatable :: h(:), w(:), a(:), b(:), sum(:)
  read(*,*) HH, WW, M
  allocate(h(M))
  allocate(w(M))
  allocate(a(HH))
  allocate(b(WW))
  allocate(sum(M))
  do i = 1, M
     read(*,*) h(i), w(i)
  end do

  a=0
  b=0
  do i = 1, M
     a(h(i))=a(h(i))+1
  end do

  do i = 1, M
     b(w(i))=b(w(i))+1
  end do

  c=maxval(a)
  d=maxval(b)

  do i = 1, HH
     if(a(i)==c) then
        nn=i
        exit
     end if
  end do

  do i = 1, WW
     if(b(i)==d) then
        n=i
        exit
     end if
  end do

  do i = 1, M
     sum(i)=h(i)+w(i)
  end do

  do i = 1, M
     if(sum(i)==c+d.and.h(i)==nn) then
        write(*,*) c+d-1
        stop
     end if
  end do

  !write(*,*) c+d
  deallocate(h)
  deallocate(w)
  deallocate(a)
  deallocate(b)
  stop
 end program answer
  