h,w,n = gets.split(" ").map(&:to_i)
h_data = {}
w_data = {}
data = []
n.times do |i|
  h_1, w_1 = gets.strip.split.map(&:to_i)
  data << [h_1, w_1] 
  if h_data.key?(h_1)
    h_data[h_1] += 1
  else
    h_data[h_1] = 1
  end
  if w_data.key?(w_1)
    w_data[w_1] += 1
  else
    w_data[w_1] = 1
  end
end

h_c = h_data.values.max
w_c = w_data.values.max

h_max = h_data.select {|k,v| v == h_c}
w_max = w_data.select {|k,v| v == w_c }


max = h_c + w_c 


h_max.each do |x, vh|
  w_max.each do |y, vy|
    if data.include?([x,y])
    else
      puts max
      exit
    end
  end
end


max -= 1

puts max
