h, w, m = gets.split(" ").map(&:to_i)

h_map = {}
w_map = {}
grid = []
while line = gets
  line_list = line.chomp.split(" ").map(&:to_i)
  t_h = line_list[0]
  t_w = line_list[1]
  grid << line_list
  if h_map.has_key?(t_h)
    h_map[t_h] += 1
  else
    h_map[t_h] = 1
  end
  if w_map.has_key?(t_w)
    w_map[t_w] += 1
  else
    w_map[t_w] = 1
  end
end

h_max = h_map.max{ |x, y| x[1] <=> y[1] }
h_max_points = []
h_map.each do |k, v|
  if v == h_max[1]
    h_max_points << k
  end
end
w_max = w_map.max{ |x, y| x[1] <=> y[1] }
w_max_points = []
w_map.each do |k, v|
  if v == w_max[1]
    w_max_points << k
  end
end

ans = h_max[1] + w_max[1]

bom_exsist = []
catch(:foo) do
  h_max_points.each do |h_max|
    w_max_points.each do |w_max|
      flg = false
      grid.each do |line|
        if line[0] == h_max && line[1] == w_max
          flg = true
        end  
      end
      bom_exsist << flg
    end
  end
end
if !bom_exsist.include?(false)
    ans -= 1
end
p ans
