h,w,m = gets.chomp.split.map(&:to_i)
targets_h = []
targets_w = []
sl = []
m.times do
  h,w = gets.chomp.split.map(&:to_i)
  targets_h << h
  targets_w << w
  sl << [h,w]
end
maxh = targets_h.uniq.max_by{|x| targets_h.count(x)}
maxw = targets_w.uniq.max_by{|y| targets_w.count(y)}
cnt = targets_h.count(maxh) + targets_w.count(maxw)
cnt -= 1 if sl.include?([maxh,maxw])
p cnt