H, W, M = gets.chomp.split(" ").map(&:to_i)
G = Array.new(H).map{Array.new(W, 0)}
R = Array.new(H, 0)
C = Array.new(W, 0)
B = Array.new(M).map{
  r, c = gets.chomp.split(" ").map(&:to_i)
  R[r-1] += 1
  C[c-1] += 1
  G[r-1][c-1] = -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

puts r_i.product(c_i).any?{|r, c| G[r][c] == 0} ? r_m+c_m : r_m+c_m-1
