from collections import deque

import heapq

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

bomb = []

heapq.heapify(bomb)

counth = [0 for k in range(H)]

countw = [0 for k in range(W)]

for k in range(M):

  h, w = list(map(int, input().split()))

  h -= 1

  w -= 1

  heapq.heappush(bomb, h+ w*H)

  counth[h] += 1 

  countw[w] += 1



counth = deque(counth)

countw = deque(countw)



maxh = max(counth)

maxw = max(countw)

index_h = deque([])

index_w = []

for k in range(H):

  h = counth.popleft()

  if h == maxh:

    index_h.append(k)

for k in range(W):

  w = countw.popleft()

  if w == maxw:

    index_w.append(k)



ans = maxh + maxw - 1

lenh = len(index_h)

lenw = len(index_w)



if lenh*lenw > M:

  ans += 1

else:

  kouho = []

  heapq.heapify(kouho)

  for i in range(lenh):

    h = index_h.pop()

    for j in range(lenw):

      w = index_w[j]

      heapq.heappush(kouho, h+ H*w)

  B = heapq.heappop(bomb)

  K = heapq.heappop(kouho)

  while True:

    if B > K:

      ans += 1

      break

    elif B == K:

      if len(kouho) == 0:

        break

      else:

        K = heapq.heappop(kouho)

    else:

      if len(bomb) == 0:

        ans += 1

        break

      else:

        B = heapq.heappop(bomb)

print(ans)



from collections import deque

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

bomb = []

counth = [0 for k in range(H)]

countw = [0 for k in range(W)]

for k in range(M):

  h, w = list(map(int, input().split()))

  h -= 1

  w -= 1

  bomb.append(h+ w*H)

  counth[h] += 1 

  countw[w] += 1



counth = deque(counth)

countw = deque(countw)



maxh = max(counth)

maxw = max(countw)

index_h = deque([])

index_w = []

for k in range(H):

  h = counth.popleft()

  if h == maxh:

    index_h.append(k)

for k in range(W):

  w = countw.popleft()

  if w == maxw:

    index_w.append(k)



ans = maxh + maxw - 1

lenh = len(index_h)

lenw = len(index_w)



if lenh*lenw > M:

  ans += 1

else:

  bomb.sort()

  bomb = deque(bomb)

  kouho = []

  for i in range(lenh):

    h = index_h.pop()

    for j in range(lenw):

      w = index_w[j]

      kouho.append(h+ H*w)

  kouho.sort()

  kouho = deque(kouho)

  B = bomb.popleft()

  K = kouho.popleft()

  while True:

    if B > K:

      ans += 1

      break

    elif B == K:

      if len(kouho) == 0:

        break

      else:

        K = kouho.popleft()

    else:

      if len(bomb) == 0:

        ans += 1

        break

      else:

        B = bomb.popleft()

print(ans)



from collections import deque
import heapq

H, W, M = list(map(int, input().split()))
bomb = []
heapq.heapify(bomb)
counth = [0 for k in range(H)]
countw = [0 for k in range(W)]
for k in range(M):
    h, w = list(map(int, input().split()))
    h -= 1
    w -= 1
    heapq.heappush(bomb, h + w * H)
    counth[h] += 1
    countw[w] += 1
counth = deque(counth)
countw = deque(countw)
maxh = max(counth)
maxw = max(countw)
index_h = deque([])
index_w = []
for k in range(H):
    h = counth.popleft()
    if h == maxh:
        index_h.append(k)
for k in range(W):
    w = countw.popleft()
    if w == maxw:
        index_w.append(k)
ans = maxh + maxw - 1
lenh = len(index_h)
lenw = len(index_w)
if lenh * lenw > M:
    ans += 1
else:
    kouho = []
    heapq.heapify(kouho)
    for i in range(lenh):
        h = index_h.pop()
        for j in range(lenw):
            w = index_w[j]
            heapq.heappush(kouho, h + H * w)
    B = heapq.heappop(bomb)
    K = heapq.heappop(kouho)
    while True:
        if B > K:
            ans += 1
            break
        elif B == K:
            if len(kouho) == 0:
                break
            else:
                K = heapq.heappop(kouho)
        else:
            if len(bomb) == 0:
                ans += 1
                break
            else:
                B = heapq.heappop(bomb)
print(ans)

from collections import deque

H, W, M = list(map(int, input().split()))
bomb = []
counth = [0 for k in range(H)]
countw = [0 for k in range(W)]
for k in range(M):
    h, w = list(map(int, input().split()))
    h -= 1
    w -= 1
    bomb.append(h + w * H)
    counth[h] += 1
    countw[w] += 1
counth = deque(counth)
countw = deque(countw)
maxh = max(counth)
maxw = max(countw)
index_h = deque([])
index_w = []
for k in range(H):
    h = counth.popleft()
    if h == maxh:
        index_h.append(k)
for k in range(W):
    w = countw.popleft()
    if w == maxw:
        index_w.append(k)
ans = maxh + maxw - 1
lenh = len(index_h)
lenw = len(index_w)
if lenh * lenw > M:
    ans += 1
else:
    bomb.sort()
    bomb = deque(bomb)
    kouho = []
    for i in range(lenh):
        h = index_h.pop()
        for j in range(lenw):
            w = index_w[j]
            kouho.append(h + H * w)
    kouho.sort()
    kouho = deque(kouho)
    B = bomb.popleft()
    K = kouho.popleft()
    while True:
        if B > K:
            ans += 1
            break
        elif B == K:
            if len(kouho) == 0:
                break
            else:
                K = kouho.popleft()
        else:
            if len(bomb) == 0:
                ans += 1
                break
            else:
                B = bomb.popleft()
print(ans)

-import heapq -heapq.heapify(bomb) -    heapq.heappush(bomb, h + w * H) +    bomb.append(h + w * H) +    bomb.sort() +    bomb = deque(bomb) -    heapq.heapify(kouho) -            heapq.heappush(kouho, h + H * w) -    B = heapq.heappop(bomb) -    K = heapq.heappop(kouho) +            kouho.append(h + H * w) +    kouho.sort() +    kouho = deque(kouho) +    B = bomb.popleft() +    K = kouho.popleft() -                K = heapq.heappop(kouho) +                K = kouho.popleft() -                B = heapq.heappop(bomb) +                B = bomb.popleft()