h, w, m = gets.split(' ').map(&:to_i)
rows = (0..h).map { 0 }
cols = (0..w).map { 0 }
map = {}
m.times do
  i, j = gets.split(' ').map(&:to_i)
  rows[i] += 1
  cols[j] += 1
  map[i] ||= {}
  map[i][j] = true
end

sorted_is = (1..h).sort_by {|i| rows[i] }
max_is = sorted_is.select {|i| rows[i] == rows[sorted_is.last] }
sorted_js = (1..w).sort_by {|j| cols[j] }
max_js = sorted_js.select {|j| cols[j] == cols[sorted_js.last] }

max_is.each do |i|
  max_js.each do |j|
    unless map[i][j]
      puts rows[i] + cols[j]
      exit
    end
  end
end
puts rows[max_is[0]] + cols[max_js[0]] - 1

