h, w, m = gets.split.map(&:to_i)
row = Array.new(h) { 0 }
col = Array.new(w) { 0 }
b = Array.new(h) { Array.new(w) { 0 } }

m.times do
  x, y = gets.split.map { |e| e.to_i - 1 }
  row[x] += 1
  col[y] += 1
  b[x][y] = 1
end

rmax = row.max
cmax = col.max
row_index = row.filter_map.with_index { |e, idx| idx if e == rmax }
col_index = col.filter_map.with_index { |e, idx| idx if e == cmax }

ans = rmax + cmax

row_index.each do |i|
  if col_index.any? { |j| b[i][j] == 0 }
    puts ans
    exit
  end
end

puts ans - 1