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.uniq!
w_list.uniq!
max = 0
h_list.each do |hl|
  w_list.each do |wl|
    max = [max, (hl + wl).uniq.length].max
  end
end
puts max