class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @h,@w,@m = gets.split.map(&:to_i)
    @a = Array.new(m){ gets.split.map(&:to_i).map{_1-1}}
  end

  def solve
    row = Array.new(h,0)
    col = Array.new(w,0)
    chk = Hash.new(false)
    a.each do |y,x|
      row[y] += 1
      col[x] += 1
      chk[[y,x]] = true
    end

    maxy = row.max
    maxx = col.max
    xs = []
    ys = []

    row.each_with_index do |y,i|
      ys << i if y == maxy
    end

    col.each_with_index do |x,i|
      xs << i if x == maxx
    end

    ys.each do |y|
      xs.each do |x|
        return maxy + maxx if !chk[[y,x]]
      end
    end
    return maxy + maxx - 1
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  show(solve)
end