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

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

x = []
xm = 0
r.each_with_index do |e, i|
    if e == xm
        x << i
    elsif e > xm
        xm = e
        x = [i]
    end
end

y = []
ym = 0
c.each_with_index do |e,i|
    if e == ym
        y << i
    elsif e > ym
        ym = e
        y = [i]
    end
end

count = 0
x.each do |ex|
    y.each do |ey|
        count += 1
        if count > m
            p xm + ym
            exit
        end

        break if !d[ex][ey]
    end or (p xm + ym; exit)
end

p xm + ym - 1