h, w, m = gets.split.map(&:to_i)
row = Array.new(h, 0)
col = Array.new(w, 0)
bomb = []
m.times do
  i, j = gets.split.map(&:to_i)
  row[i-1] += 1
  col[j-1] += 1
  bomb << [i-1, j-1]
end
row_bomb_max = row.max
col_bomb_max = col.max
ans = row_bomb_max + col_bomb_max
row_num = row.count(row_bomb_max)
col_num = col.count(col_bomb_max)
cnt = row_num * col_num
bomb.each do |i, j|
  cnt -= 1 if row[i]==row_bomb_max && col[j]==col_bomb_max
end
puts cnt == 0 ? ans - 1 : ans