import sys

from bisect import bisect_left as bl

input = sys.stdin.readline

H, W, N = list(map(int, input().split()))

ys = [0] * (H + 1)

xs = [0] * (W + 1)

a = []

base = 10 ** 6

for i in range(N):

  y, x = list(map(int, input().split()))

  ys[y] += 1

  xs[x] += 1

  a.append((y, x))

sy = sorted(ys[1: ])

sx = sorted(xs[1: ])

#print(sy, sx)

def check(k):

  res = 0

  for y, x in a:

    res -= (ys[y] + xs[x]) == k

    res += (ys[y] + xs[x]) > k



  #print(res, k)

  for y in sy:

    i = bl(sx, k - y)

    res += W - i

    #print(W - i, y, k, res)

  return res > 0



ok = 0

ng = N + 1

while ng - ok > 1:

  m = (ok + ng) // 2

  if check(m): ok = m

  else: ng = m

print(ok)
import sys

input = sys.stdin.readline

H, W, M = list(map(int, input().split()))

s = set()

ys = [0] * (H + 1)

xs = [0] * (W + 1)

for _ in range(M):

  y, x = list(map(int, input().split()))

  s.add((y, x))

  ys[y] += 1

  xs[x] += 1



res = 0

mxy = []

mx = max(ys)

for i in range(H + 1):

  if ys[i] == mx: mxy.append(i)

res += mx



mxx = []

mx = max(xs)

for i in range(W + 1):

  if xs[i] == mx: mxx.append(i)

res += mx - 1



for x in mxx:

  for y in mxy:

    if (y, x) in s: continue

    res += 1

    break

  else: continue

  break

print(res)
import sys
from bisect import bisect_left as bl

input = sys.stdin.readline
H, W, N = list(map(int, input().split()))
ys = [0] * (H + 1)
xs = [0] * (W + 1)
a = []
base = 10**6
for i in range(N):
    y, x = list(map(int, input().split()))
    ys[y] += 1
    xs[x] += 1
    a.append((y, x))
sy = sorted(ys[1:])
sx = sorted(xs[1:])
# print(sy, sx)
def check(k):
    res = 0
    for y, x in a:
        res -= (ys[y] + xs[x]) == k
        res += (ys[y] + xs[x]) > k
    # print(res, k)
    for y in sy:
        i = bl(sx, k - y)
        res += W - i
        # print(W - i, y, k, res)
    return res > 0


ok = 0
ng = N + 1
while ng - ok > 1:
    m = (ok + ng) // 2
    if check(m):
        ok = m
    else:
        ng = m
print(ok)

import sys

input = sys.stdin.readline
H, W, M = list(map(int, input().split()))
s = set()
ys = [0] * (H + 1)
xs = [0] * (W + 1)
for _ in range(M):
    y, x = list(map(int, input().split()))
    s.add((y, x))
    ys[y] += 1
    xs[x] += 1
res = 0
mxy = []
mx = max(ys)
for i in range(H + 1):
    if ys[i] == mx:
        mxy.append(i)
res += mx
mxx = []
mx = max(xs)
for i in range(W + 1):
    if xs[i] == mx:
        mxx.append(i)
res += mx - 1
for x in mxx:
    for y in mxy:
        if (y, x) in s:
            continue
        res += 1
        break
    else:
        continue
    break
print(res)

-from bisect import bisect_left as bl -H, W, N = list(map(int, input().split())) +H, W, M = list(map(int, input().split())) +s = set() -a = [] -base = 10**6 -for i in range(N): +for _ in range(M): +    s.add((y, x)) -    a.append((y, x)) -sy = sorted(ys[1:]) -sx = sorted(xs[1:]) -# print(sy, sx) -def check(k): -    res = 0 -    for y, x in a: -        res -= (ys[y] + xs[x]) == k -        res += (ys[y] + xs[x]) > k -    # print(res, k) -    for y in sy: -        i = bl(sx, k - y) -        res += W - i -        # print(W - i, y, k, res) -    return res > 0 - - -ok = 0 -ng = N + 1 -while ng - ok > 1: -    m = (ok + ng) // 2 -    if check(m): -        ok = m +res = 0 +mxy = [] +mx = max(ys) +for i in range(H + 1): +    if ys[i] == mx: +        mxy.append(i) +res += mx +mxx = [] +mx = max(xs) +for i in range(W + 1): +    if xs[i] == mx: +        mxx.append(i) +res += mx - 1 +for x in mxx: +    for y in mxy: +        if (y, x) in s: +            continue +        res += 1 +        break -        ng = m -print(ok) +        continue +    break +print(res)