line = gets()
h, w, m = line.chomp.split(' ').map{|i| i.to_i}

point =[]
m.times do |i|
    line = gets().chomp
    hi, wi = line.split(' ').map { |e| e.to_i }
    point.push([hi-1, wi-1])
end

total =Hash.new
hcount = Array.new(h) {|i| i = 0}
wcount = Array.new(w) {|i| i = 0}

m.times do |i|
    tmp = point[i]
    y = tmp[0] 
    x = tmp[1] 

    total[y*w + x] = 1
    hcount[y] += 1
    wcount[x] += 1
end

max_b = 0
#area = h*w
h.times do |j|
    w.times do |i|
        tmp = hcount[j] + wcount[i]
        #if total[i + j*w] == 1
        if total.keys.include?(j*w+i)
            tmp -= 1
        end
        if tmp > max_b
            max_b = tmp
        end
    end
end

puts(total)
print(max_b)