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

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

count_h = count_h.map.with_index{[_1,_2]}.sort.reverse
count_w = count_w.map.with_index{[_1,_2]}.sort.reverse

w_max = count_w[0][0]

ans = 0
count_h.each do |ch,h|
    next if ch + w_max <= ans

    targets_h = targets[h]
    count_w.each do |cw,w|
        c = ch+cw
        break if c <= ans
        c -= 1 if targets_h[w]
        ans = c if ans < c
    end
end

p ans