h, w, m = gets.split(' ').map(&:to_i)
tbl = m.times.map { gets.split(' ').map(&:to_i) }
h_sum = [0] * h
w_sum = [0] * w

tbl.each do |i, j|
  h_sum[i-1] = h_sum[i-1] + 1
  w_sum[j-1] = w_sum[j-1] + 1
end

sum_tbl = (0..h-1).map do |i|
  (0..w-1).map do |j|
    h_sum[i] + w_sum[j]
  end
end

tbl.each do |i, j|
  sum_tbl[i-1][j-1] -= 1
end

puts sum_tbl.flatten.max

