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

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
end

hmax = h_grid.max
wmax = w_grid.max
h_arr = h_grid.map.with_index{|hi, i| hi == hmax ? i : nil }.compact
w_arr = w_grid.map.with_index{|wi, i| wi == wmax ? i : nil }.compact

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

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

