H, W, M = gets.split.map(&:to_i)
B = M.times.map{ gets.split.map(&:to_i) }
R = Array.new(H + 1, 0)
C = Array.new(W + 1, 0)

B.each do |h,w|
  R[h] += 1
  C[w] += 1
end

Rmax = R.max
Cmax = C.max

Rcount = R.count(Rmax)
Ccount = C.count(Cmax)

if Rcount * Ccount > B.count{|h,w| R[h] == Rmax && C[w]  == Cmax }
  puts Rmax + Cmax
else
  puts Rmax + Cmax - 1
end

