h, w, m = gets.split(" ").map(&:to_i)
grid = {}
h_grid = Array.new(h+1, 0)
w_grid = Array.new(w+1, 0)

hmax = h_grid.max
h_arr = []
wmax = w_grid.max
w_arr = []

m.times do
  hi, wi = gets.split(" ").map(&:to_i)
  grid[[hi, wi]] = true
  h_grid[hi] ||= 0
  w_grid[wi] ||= 0
  h_grid[hi] += 1
  w_grid[wi] += 1
  
  if h_grid[hi] > hmax
    hmax = h_grid[hi]
    h_arr = [hi]
  elsif h_grid[hi] == hmax
    h_arr << hi
  end
  if w_grid[wi] > wmax
    wmax = w_grid[wi]
    w_arr = [wi]
  elsif w_grid[wi] == wmax
    w_arr << wi
  end
end

bomb = true
h_arr.each do |i|
  w_arr.each do |j|
    bomb = false unless grid[[i, j]]
    break unless bomb
  end
  break unless bomb
end

puts hmax + wmax + (bomb ? -1 : 0)

