require "set"

h, w, m = gets.split.map {|s| s.to_i}
items = m.times.map {gets.split.map {|s| s.to_i-1}}

hs = h.times.map {|i| [i, 0, Set.new]}
ws = w.times.map {|i| [i, 0]}
items.each do |(i, j)|
	hs[i][1] += 1
	hs[i][2] << j
	ws[j][1] += 1
end

hs = hs.sort_by { |h| -h[1] }
ws = ws.sort_by { |w| -w[1] }

#p hs, ws
c_max = 0
[10, h].min.times do |i|
	[10, w].min.times do |j|
		c = hs[i][1] + ws[j][1]
		c -= 1 if hs[i][2].include? ws[j][0]
		c_max = c if c_max < c
	end
end
p c_max