h,w,n = gets.split(" ").map(&:to_i)
h_data = Array.new(h+1, 0)
w_data = Array.new(w+1, 0)
data = Hash.new(false)
n.times do |i|
  h_1, w_1 = gets.strip.split.map(&:to_i)
  data[[h_1, w_1]] = true 
  h_data[h_1] += 1
  w_data[w_1] += 1
end

h_c = h_data.max
w_c = w_data.max

h_max = []
w_max = []

h_data.each_with_index do |i, index|
  if i == h_c
    h_max << index
  end
end
    
w_data.each_with_index do |j, index|
  if j == w_c
    w_max << index
  end
end


max = h_c + w_c 


h_max.each do |x|
  w_max.each do |y|
    if data[[x,y]]
    else
      puts max
      exit
    end
  end
end


max -= 1

puts max
