program bomber
  implicit none
  integer :: h, w, m, nx, ny, mx = 0, my = 0, d, i
  integer, dimension(300000) :: x = 0, y = 0, a = 0, b = 0
  logical, dimension(300000) :: ux = .false., uy = .false.
  read(*,*) h, w, m
  do i = 1, m
    read(*,*) x(i), y(i)
    a(x(i)) = a(x(i)) + 1
    b(y(i)) = b(y(i)) + 1
  end do
  nx = maxval(a(1:h))
  ny = maxval(b(1:w))
  do i = 1, h
    if (a(i) == nx) then
      ux(i) = .true.
      mx = mx + 1
    end if
  end do
  do i = 1, w
    if (b(i) == ny) then
      uy(i) = .true.
      my = my + 1
    end if
  end do
  d = mx * my
  do i = 1, m
    if (ux(x(i)) .and. uy(y(i))) d = d - 1
  end do
  write(*,'(i0)') nx + ny - merge(1, 0, d == 0)
end program bomber