H,W,M = gets.split.map &:to_i
HW = M.times.map{ gets.split.map{_1.to_i - 1}}

H = W = 3 * (10**5)

count_h = [0]*H
count_w = [0]*W
targets = Array.new(H){[]}
HW.each do |h,w|
    count_h[h] += 1
    count_w[w] += 1
    targets[h][w] = true
end

ans = 0
H.times do |h|
    c = count_h[h]
    next if c == 0
    targets_h = targets[h]
    W.times do |w|
        cnt = c + count_w[w] || 0
        next if cnt==0 
        cnt -= 1 if targets_h[w]
        ans = cnt if ans < cnt
    end
end

p ans