h, w, m = gets.split.map(&:to_i)
rows = Array.new(h+1, 0)
cols = Array.new(w+1, 0)
nodes = []
m.times do
  nh, nw = gets.split.map(&:to_i)
  nodes << [nh, nw]
  rows[nh] += 1
  cols[nw] += 1
end
rmax = rows.max
rcount = rows.count(rmax)
cmax = cols.max
ccount = cols.count(cmax)

if rcount * ccount > nodes.count{ rows[_1] == rmax && cols[_2] == cmax }
  puts rmax + cmax
else
  puts rmax + cmax - 1
end
