h, w, m = gets.split.map(&:to_i)
x = Array.new(h, 0)
y = Array.new(w, 0)
z = []
m.times do
  hm, wm = gets.split.map(&:to_i)
  x[hm-1] += 1
  y[wm-1] += 1
  z << [hm, wm]
end
x_max = x.max
y_max = y.max
ans = x_max + y_max

h.times do |i|
  w.times do |j|
    q = x[i] + y[j]
    next unless q == ans

    is_cross = false
    z.each do |point|
      if i==(point[0]-1) && j==(point[1]-1)
        is_cross = true
        break
      end
    end
    unless is_cross
      puts ans
      exit
    end
  end
end
puts ans - 1