program bomber
  implicit none
  integer :: h, w, m, nx, ny, mx = 0, my = 0, d, i
  integer, dimension(300000) :: x = 0, y = 0, cx = 0, cy = 0
  read(*,*) h, w, m
  do i = 1, m
    read(*,*) x(i), y(i)
    cx(x(i)) = cx(x(i)) + 1
    cy(y(i)) = cy(y(i)) + 1
  end do
  nx = maxval(cx(1:h))
  ny = maxval(cy(1:w))
  do i = 1, h
    if (cx(i) == nx) mx = mx + 1
  end do
  do i = 1, w
    if (cy(i) == ny) my = my + 1
  end do
  d = mx * my
  do i = 1, m
    if (cx(x(i)) == nx .and. cy(y(i)) == ny) d = d - 1
  end do
  write(*,'(i0)') nx + ny - merge(1, 0, d == 0)
end program bomber