H, W, M = gets.chomp.split(" ").map(&:to_i)
R = Array.new(H, 0)
C = Array.new(W, 0)
G = Array.new(M).map{
  r, c = gets.chomp.split(" ").map(&:to_i)
  R[r-1] += 1
  C[c-1] += 1
  (r-1)*W+c-1
}

r_m, c_m = R.max, C.max
r_i = R.map.with_index{|r, i| r==r_m ? i : nil}.compact
c_i = C.map.with_index{|c, i| c==c_m ? i : nil}.compact
G.sort!
flg = false
r_i.each{|r|
  c_i.each{|c|
    flg = true if G.bsearch{|x| x>=r*W+c} != r*W+c
  }
  break if flg
}

puts flg ? r_m+c_m : r_m+c_m-1
