# after YouTube explanation
require 'set'
h,w,m = gets.strip.split.map(&:to_i)
hs = Array.new(h,0)
ws = Array.new(w,0)
s = Set.new
m.times do
  x,y = gets.strip.split.map{|e| e.to_i - 1}
  hs[x] += 1
  ws[y] += 1
  s.add [x,y]
end
hx = hs.max
wx = ws.max
is = []
js = []
ans = hx + wx
h.times {|i| is.push i if hx == hs[i]}
w.times {|j| js.push j if wx == ws[j]}
is.each {|i| js.each {|j|
  next if s.include?([i,j])
  p ans
  exit
}}
p ans - 1
