h,w,m = gets.chomp.split.map(&:to_i)
targets_h = Array.new(h,0)
targets_w = Array.new(w,0)
targets = []
m.times do 
  h,w = gets.chomp.split.map(&:to_i)
  targets_h[h-1] +=1
  targets_w[w-1] +=1
  targets << [h,w]
end
maxh = targets_h.max
maxw = targets_w.max
ans = maxh + maxw
maxcnt = targets_h.count(maxh) * targets_w.count(maxw)
targets.each do |h,w|
  maxcnt -=1 if targets_h[h-1] == maxh && targets_w[w-1] == maxw
end
if maxcnt == 0
  puts ans-1
else
  puts ans
end