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

r = Array.new(h+1) {|i| [i,0]}
c = Array.new(w+1) {|i| [i,0]}
d = Array.new(h+1) {Array.new(w+1,0)}
m.times do
    a, b = gets.split.map(&:to_i)
    r[a][1] += 1
    c[b][1] += 1
    d[a][b] += 1
end

r.sort_by!{|a,b| -b}
c.sort_by!{|a,b| -b}

x = r[0][1]
y = c[0][1]
ans = x + y - 1
r.each do |a,b|
    break if x != b
    c.each do |aa,bb|
        break 1 if y != bb
        break if d[a][aa] == 0
    end or (ans += 1; break)
end

p ans