program main
  implicit none
  integer(8) i,H,W,M,x,y,b,ans,j,Hmax,Wmax,NHmax,NWmax
  integer(8),allocatable :: A(:,:), Hsum(:), Wsum(:), iH(:), iW(:)
  read(*, *)H,W,M
  allocate(A(H,W))
  allocate(Hsum(H))
  allocate(Wsum(W))
  allocate(iH(M))
  allocate(iW(M))
  A = 0
  Hsum = 0
  Wsum = 0
  do i = 1,M
    read(*, *) x,y
    A(x,y) = 1
    iH(i) = x
    iW(i) = y
    Hsum(x) = Hsum(x)+1
    Wsum(y) = Wsum(y)+1
  end do

  Hmax = maxval(Hsum)
  Wmax = maxval(Wsum)

  ans = 1
  do i = 1,H
    if (Hsum(i) == Hmax .and. ans == 1) then
      do j = 1,W
        if (Wsum(j) == Wmax) then
          if (A(i,j) == 0) then
            ans = 0
            exit
          end if
        end if
      end do
    end if
  end do
  
  write(*, *) Hmax + Wmax - ans
end program main
