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 = {}
h_key_max = 0
w_key_max = 0

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)
  h_key_max = h_key if h_key > h_key_max
  w_key_max = w_key if w_key > w_key_max
end

res = [0]
h_rev[h_key_max].each do |tmp_h|
  w_rev[w_key_max].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
