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|
  nodes[i] = gets.split.map(&:to_i)
  h_list[nodes[i][0]] << i
  w_list[nodes[i][1]] << i
end
h_list.compact!
h_list.sort_by!{_1.length * -1}
h_last_idx = 0
h_list.each.with_index { |l, idx| break if l.length < h_list.first.length; h_last_idx = idx; }
w_list.compact!
w_list.sort_by!{_1.length * -1}
w_last_idx = 0
w_list.each.with_index { |l, idx| break if l.length < w_list.first.length; w_last_idx = idx; }
max = 0
h_list[0..h_last_idx].each do |hl|
  w_list[0..w_last_idx].each do |wl|
    max = [max, (hl + wl).uniq.length].max
  end
end
puts max