input = readlines()

h, w, m = input.shift().chomp().split("\s").map{|x| x.to_i}

h_list = {}
w_list = {}
h_rev = {}
w_rev = {}
pos_list = {}

input.each do |vals|
  ch, cw = vals.chomp.split("\s").map{|x| x.to_i}
  h_list[ch] = 0 if h_list[ch].nil?
  h_list[ch] += 1
  w_list[cw] = 0 if w_list[cw].nil?
  w_list[cw] += 1
  pos_list["#{ch}-#{cw}"] = true

  h_key = h_list[ch]
  w_key = w_list[cw]
  h_rev[h_key] = [] if h_rev[h_key].nil?
  w_rev[w_key] = [] if w_rev[w_key].nil?
  h_rev[h_key].push(ch)
  w_rev[w_key].push(cw)
end

h_key_sorted = h_rev.keys.to_a.sort.reverse
w_key_sorted = w_rev.keys.to_a.sort.reverse

res = [0]
# if h_rev.keys.length == 0
#   res.push(w_list[w_key_sorted[0]][0])
# end
# if w_rev.keys.length == 0
#   res.push(h_list[h_key_sorted[0]][0])
# end
h_rev[h_key_sorted[0]].each do |tmp_h|
  w_rev[w_key_sorted[0]].each do |tmp_w|
    cnt = h_list[tmp_h] + w_list[tmp_w]
    cnt -= 1 if pos_list["#{tmp_h}-#{tmp_w}"] == true
    res.push(cnt)
  end
end

puts res.max
