h,w,n = gets.split(" ").map(&:to_i)
data = n.times.map { gets.strip.split.map(&:to_i) }
h_data = {}
w_data = {}

data.each do |i|
  h_1 = i[0]
  w_1 = i[1]
  if h_data.key?(h_1)
    h_data[h_1] += 1
  else
    h_data[h_1] = 1
  end
  if w_data.key?(w_1)
    w_data[w_1] += 1
  else
    w_data[w_1] = 1
  end
end

h_c = h_data.values.max
w_c = w_data.values.max

h_max = h_data.select {|k,v| v == h_c}
w_max = w_data.select {|k,v| v == w_c }


max = h_c + w_c 



h_k= h_max.keys
w_k= w_max.keys

marker = 0
cnt = 0

h_k.each do |x|
  w_k.each do |y|
    if data.include?([x,y])
    else
      marker = 1
    end
    break if marker == 1
  end
  break if marker == 1
end


if marker == 0
  max -= 1
end

puts max
