local read = io.read
local insert = table.insert

local h, w, m = read("n", "n", "n")
local grid = {}
for i = 1, m do
	grid[i] = {}
end

local sum_h, sum_w = {}, {}
for i = 1, m do
	local hs = read("n")
	local ws = read("n")
	grid[hs][ws] = 1
	sum_h[hs] = sum_h[hs] and sum_h[hs] + 1 or 1
	sum_w[ws] = sum_w[ws] and sum_w[ws] + 1 or 1
end

local max_h, max_w = 0, 0
local max_hs, max_ws
for i = 1, m do
	if sum_h[i] and sum_h[i] > max_h then
		max_h = sum_h[i]
		max_hs = {i}
	elseif sum_h[i] and sum_h[i] == max_h then
		insert(max_hs, i)
	end
	if sum_w[i] and sum_w[i] > max_w then
		max_w = sum_w[i]
		max_ws = {i}
	elseif sum_w[i] and sum_w[i] == max_w then
		insert(max_ws, i)
	end
end

local is_dup = true
for i = 1, #max_hs do
	for j = 1, #max_ws do
		if grid[max_hs[i]][max_ws[j]] == nil then
			is_dup = false
		end
	end
end

print(is_dup and max_h + max_w - 1 or max_h + max_w)
