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
HW.each do |h,w|
    count_h[h] += 1
    count_w[w] += 1
end

h_max = count_h.max
is_max_h = count_h.map{ _1 == h_max}
w_max = count_w.max
is_max_w = count_w.map{ _1 == w_max}

HW.each do |h,w|
    is_max_h[h] = false
    is_max_w[w] = false
end

ans = h_max + w_max
ans -= (is_max_h.any? && is_max_w.any?) ? 0 : 1

p ans