require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
h,w,m = gets.chomp.split.map(&:to_i)
set = Set.new
rows = Array.new(h, 0)
cols = Array.new(w, 0)
m.times do
  y,x = gets.chomp.split.map{|e| e.to_i - 1}
  rows[y] += 1
  cols[x] += 1
  set.add [y, x]
end

# rowmax = row.max
# colmax = col.max

rows = rows.zip((0...h).to_a)
cols = cols.zip((0...w).to_a)

# rows0 = rows.select{|row| row[0] == rowmax}
# cols0 = cols.select{|col| col[0] == colmax}

# if

rows.sort_by!{|v, i| -v}
cols.sort_by!{|v, i| -v}

rowmax = rows[0][0]
colmax = cols[0][0]

ans = 0
rows.each do |row_v, row_i|
  break if row_v < rowmax - 1
  cols.each do |col_v, col_i|
    break if col_v < colmax - 1
    if set.include? [row_i, col_i]
      tmp = row_v + col_v - 1
    else
      tmp = row_v + col_v
    end
    ans = [ans, tmp].max
  end
end

# p rows
# p cols
puts ans




