h, w, m = gets.split.map(&:to_i)
pos = []
h_list = {}
h_max = 0
w_list = {}
w_max = 0
m.times do
  nh, nw = gets.split.map(&:to_i)
  pos << nh * h + nw
  h_list[nh] = 0 unless h_list[nh]
  w_list[nw] = 0 unless w_list[nw]
  h_list[nh] += 1
  w_list[nw] += 1
  h_max = [h_max, h_list[nh]].max
  w_max = [w_max, w_list[nw]].max
end
pos.sort!
mmax = h_max + w_max
h_list.select!{ |_, v| v == h_max }
w_list.select!{ |_, v| v == w_max }
h_max_keys = h_list.keys
w_max_keys = w_list.keys
h_max_keys.each do |hmk|
  w_max_keys.each do |wmk|
    unless pos.include?(hmk * h + wmk)
      puts mmax
      exit 0
    end
  end
end
puts mmax - 1
