import numpy as np
import sys
read = sys.stdin.read

if sys.argv[-1] == 'ONLINE_JUDGE':
	from numba.pycc import CC
	cc = CC('unko')

	@cc.export('solve', '(i4[:],)')
	def solve(stdin):
		h, w, m = stdin[:3]

		row = np.zeros(h, np.int32)
		col = np.zeros(w, np.int32)
		for i in range(3, m * 2 + 3, 2):
			y, x = stdin[i: i + 2] - 1
			row[y] += 1
			col[x] += 1

		max_cnt_y = max(row)
		max_cnt_x = max(col)
		max_pair = np.sum(row == max_cnt_y) * np.sum(col == max_cnt_x)
		for i in range(3, m * 2 + 3, 2):
			y, x = stdin[i: i + 2] - 1
			if row[y] == max_cnt_y and col[x] == max_cnt_x:
				max_pair -= 1

		return max_cnt_y + max_cnt_x - (max_pair == 0)
	
	cc.compile()
	exit()

from unko import solve
print(solve(np.fromstring(read(), dtype=np.int32, sep=' '))) import numpy as np numpy import sys sys read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read if sys.argv[-1] == 'ONLINE_JUDGE':
	from numba.pycc import CC
	cc = CC('unko')

	@cc.export('solve', '(i4[:],)')
	def solve(stdin):
		h, w, m = stdin[:3]

		row = np.zeros(h, np.int32)
		col = np.zeros(w, np.int32)
		for i in range(3, m * 2 + 3, 2):
			y, x = stdin[i: i + 2] - 1
			row[y] += 1
			col[x] += 1

		max_cnt_y = max(row)
		max_cnt_x = max(col)
		max_pair = np.sum(row == max_cnt_y) * np.sum(col == max_cnt_x)
		for i in range(3, m * 2 + 3, 2):
			y, x = stdin[i: i + 2] - 1
			if row[y] == max_cnt_y and col[x] == max_cnt_x:
				max_pair -= 1

		return max_cnt_y + max_cnt_x - (max_pair == 0)
	
	cc.compile()
	exit() sys.argv[-1] == 'ONLINE_JUDGE' sys.argv[-1] sys.argv sys argv -1 'ONLINE_JUDGE' from numba.pycc import CC cc = CC('unko') cc CC('unko') CC 'unko' def solve(stdin):
		h, w, m = stdin[:3]

		row = np.zeros(h, np.int32)
		col = np.zeros(w, np.int32)
		for i in range(3, m * 2 + 3, 2):
			y, x = stdin[i: i + 2] - 1
			row[y] += 1
			col[x] += 1

		max_cnt_y = max(row)
		max_cnt_x = max(col)
		max_pair = np.sum(row == max_cnt_y) * np.sum(col == max_cnt_x)
		for i in range(3, m * 2 + 3, 2):
			y, x = stdin[i: i + 2] - 1
			if row[y] == max_cnt_y and col[x] == max_cnt_x:
				max_pair -= 1

		return max_cnt_y + max_cnt_x - (max_pair == 0)
	
	 solve h, w, m = stdin[:3] h stdin[:3] stdin :3 3 w m row = np.zeros(h, np.int32) row np.zeros(h, np.int32) np.zeros np zeros h np.int32 np int32 col = np.zeros(w, np.int32) col np.zeros(w, np.int32) np.zeros np zeros w np.int32 np int32 for i in range(3, m * 2 + 3, 2):
			y, x = stdin[i: i + 2] - 1
			row[y] += 1
			col[x] += 1

		 i range(3, m * 2 + 3, 2) range 3 m * 2 + 3 m * 2 m 2 3 2 y, x = stdin[i: i + 2] - 1 y stdin[i: i + 2] - 1 stdin[i: i + 2] stdin i: i + 2 i i + 2 i 2 1 x row[y] += 1 row[y] row y 1 col[x] += 1 col[x] col x 1 max_cnt_y = max(row) max_cnt_y max(row) max row max_cnt_x = max(col) max_cnt_x max(col) max col max_pair = np.sum(row == max_cnt_y) * np.sum(col == max_cnt_x) max_pair np.sum(row == max_cnt_y) * np.sum(col == max_cnt_x) np.sum(row == max_cnt_y) np.sum np sum row == max_cnt_y row max_cnt_y np.sum(col == max_cnt_x) np.sum np sum col == max_cnt_x col max_cnt_x for i in range(3, m * 2 + 3, 2):
			y, x = stdin[i: i + 2] - 1
			if row[y] == max_cnt_y and col[x] == max_cnt_x:
				max_pair -= 1

		 i range(3, m * 2 + 3, 2) range 3 m * 2 + 3 m * 2 m 2 3 2 y, x = stdin[i: i + 2] - 1 y stdin[i: i + 2] - 1 stdin[i: i + 2] stdin i: i + 2 i i + 2 i 2 1 x if row[y] == max_cnt_y and col[x] == max_cnt_x:
				max_pair -= 1

		 row[y] == max_cnt_y and col[x] == max_cnt_x row[y] == max_cnt_y row[y] row y max_cnt_y col[x] == max_cnt_x col[x] col x max_cnt_x max_pair -= 1 max_pair 1 return max_cnt_y + max_cnt_x - (max_pair == 0) max_cnt_y + max_cnt_x - (max_pair == 0) max_cnt_y + max_cnt_x max_cnt_y max_cnt_x max_pair == 0 max_pair 0 stdin stdin @cc.export('solve', '(i4[:],)')
	 solve 'solve', '(i4[:],)' @cc.export('solve', '(i4[:],)')
	 cc.export 'solve' '(i4[:],)' solve cc.compile() cc.compile cc compile exit() exit from unko import solve print(solve(np.fromstring(read(), dtype=np.int32, sep=' '))) print solve(np.fromstring(read(), dtype=np.int32, sep=' ')) solve np.fromstring(read(), dtype=np.int32, sep=' ') np.fromstring np fromstring read() read dtype=np.int32 dtype np.int32 np int32 sep=' ' sep ' ' def solve(stdin):
		h, w, m = stdin[:3]

		row = np.zeros(h, np.int32)
		col = np.zeros(w, np.int32)
		for i in range(3, m * 2 + 3, 2):
			y, x = stdin[i: i + 2] - 1
			row[y] += 1
			col[x] += 1

		max_cnt_y = max(row)
		max_cnt_x = max(col)
		max_pair = np.sum(row == max_cnt_y) * np.sum(col == max_cnt_x)
		for i in range(3, m * 2 + 3, 2):
			y, x = stdin[i: i + 2] - 1
			if row[y] == max_cnt_y and col[x] == max_cnt_x:
				max_pair -= 1

		return max_cnt_y + max_cnt_x - (max_pair == 0)
	
	 def solve(stdin):
		h, w, m = stdin[:3]

		row = np.zeros(h, np.int32)
		col = np.zeros(w, np.int32)
		for i in range(3, m * 2 + 3, 2):
			y, x = stdin[i: i + 2] - 1
			row[y] += 1
			col[x] += 1

		max_cnt_y = max(row)
		max_cnt_x = max(col)
		max_pair = np.sum(row == max_cnt_y) * np.sum(col == max_cnt_x)
		for i in range(3, m * 2 + 3, 2):
			y, x = stdin[i: i + 2] - 1
			if row[y] == max_cnt_y and col[x] == max_cnt_x:
				max_pair -= 1

		return max_cnt_y + max_cnt_x - (max_pair == 0)
	
	 solve cc = CC('unko') CC('unko') cc read = sys.stdin.read sys.stdin.read read
import numpy as np
import sys
read = sys.stdin.read

if sys.argv[-1] == 'ONLINE_JUDGE':
	from numba.pycc import CC
	cc = CC('unko')

	@cc.export('solve', '(i4[:],)')
	def solve(stdin):
		h, w, m = stdin[:3]

		row = np.zeros(h, np.int32)
		col = np.zeros(w, np.int32)
		for i in range(3, m * 2 + 3, 2):
			y, x = stdin[i: i + 2] - 1
			row[y] += 1
			col[x] += 1

		max_cnt_y = max(row)
		max_cnt_x = max(col)
		max_pair = np.sum(row == max_cnt_y) * np.sum(col == max_cnt_x)
		for i in range(3, m * 2 + 3, 2):
			y, x = stdin[i: i + 2] - 1
			if row[y] == max_cnt_y and col[x] == max_cnt_x:
				max_pair -= 1

		return max_cnt_y + max_cnt_x - (max_pair == 0)
	
	cc.compile()
	exit()

from unko import solve
print(solve(np.fromstring(read(), dtype=np.int32, sep=' ')))