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
end

h_max = count_h.max
max_idxs_h = count_h.map.with_index{|c,i| c==h_max ? i : nil}.compact
w_max = count_w.max
max_idxs_w = count_w.map.with_index{|c,i| c==w_max ? i : nil}.compact

no_cross = max_idxs_h.any? do |h|
    max_idxs_w.difference(targets[h]).any?
end

ans = h_max + w_max
ans -= (no_cross) ? 0 : 1

p ans