# reference
# https://atcoder.jp/contests/abc176/submissions/16207205
# https://qiita.com/QUANON/items/ca06f3068c87b3a21e18

H, W, M = gets.strip.split.map(&:to_i)

m = []
M.times do
  m.push(gets.strip.split.map { |_| _.to_i - 1 })
end

hx, hh = 0, [0] * H
wx, ww = 0, [0] * W

m.each { |h, w|
  hx = hh[h] if hx < hh[h] += 1
  wx = ww[w] if wx < ww[w] += 1
}

hi = hh.filter_map.with_index { |e, i| i if e == hx }
wi = hh.filter_map.with_index { |e, i| i if e == wx }


hi.each do |i|
  wi.each do |j|
    return p hx + wx unless m.include?([i, j])
  end
end

p hx + wx - 1
