h, w, m = gets.split.map(&:to_i)
nodes = []
h_list = Array.new(h+1) { [] }
w_list = Array.new(w+1) { [] }
m.times do |i|
  nh, nw = gets.split.map(&:to_i)
  nodes[i] = [nh, nw]
  h_list[nh] << i
  w_list[nw] << i
end
h_max = 0
h_list.compact!
h_list.each { h_max = [h_max, _1.size].max }
h_list = h_list.select{ _1.size == h_max }
w_max = 0
w_list.compact!
w_list.each { w_max = [w_max, _1.size].max }
w_list = w_list.select{ _1.size == w_max }
max = 0
h_list.each do |hl|
  w_list.each do |wl|
    max = [max, (hl + wl).uniq.length].max
  end
end
puts max