import numpy as np





def pd(s):

    # print(s)

    pass





# input

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

ms = [

    [int(i) for i in input().split()]

    for m in range(M)

]

pd(f"{H=} {W=} {M=}")

pd(f"{ms=}")



rows = [0]*(H+1)

cols = [0]*(W+1)

bombs = {}

for m in ms:

    h = m[0]

    w = m[1]

    rows[h] += 1

    cols[w] += 1

    bombs[f"{h},{w}"] = True



rmax = max(rows)

cmax = max(cols)

rmax_hs = [i for i, v in enumerate(rows) if v == rmax]

cmax_wh = [i for i, v in enumerate(cols) if v == cmax]



for h in rmax_hs:

    for w in cmax_wh:

        if f"{h},{w}" not in bombs:

            print((rmax + cmax))

            exit()

print((rmax + cmax - 1))

import numpy as np

import itertools





def pd(s):

    #print(s)

    pass





# input

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

ms = [

    [int(i) for i in input().split()]

    for m in range(M)

]

pd(f"{H=} {W=} {M=}")

pd(f"{ms=}")



rows = [0]*(H+1)

cols = [0]*(W+1)

bombs = {}

for h,w in ms:

    rows[h] += 1

    cols[w] += 1

    bombs[f"{h},{w}"] = True



rmax = max(rows)

cmax = max(cols)

rmax_hs = [i for i, v in enumerate(rows) if v == rmax]

cmax_wh = [i for i, v in enumerate(cols) if v == cmax]



for h,w in itertools.product(rmax_hs, cmax_wh):

    if f"{h},{w}" not in bombs:

        print((rmax + cmax))

        exit()

print((rmax + cmax - 1))

import numpy as np


def pd(s):
    # print(s)
    pass


# input
H, W, M = list(map(int, input().split()))
ms = [[int(i) for i in input().split()] for m in range(M)]
pd(f"{H=} {W=} {M=}")
pd(f"{ms=}")
rows = [0] * (H + 1)
cols = [0] * (W + 1)
bombs = {}
for m in ms:
    h = m[0]
    w = m[1]
    rows[h] += 1
    cols[w] += 1
    bombs[f"{h},{w}"] = True
rmax = max(rows)
cmax = max(cols)
rmax_hs = [i for i, v in enumerate(rows) if v == rmax]
cmax_wh = [i for i, v in enumerate(cols) if v == cmax]
for h in rmax_hs:
    for w in cmax_wh:
        if f"{h},{w}" not in bombs:
            print((rmax + cmax))
            exit()
print((rmax + cmax - 1))

import numpy as np
import itertools


def pd(s):
    # print(s)
    pass


# input
H, W, M = list(map(int, input().split()))
ms = [[int(i) for i in input().split()] for m in range(M)]
pd(f"{H=} {W=} {M=}")
pd(f"{ms=}")
rows = [0] * (H + 1)
cols = [0] * (W + 1)
bombs = {}
for h, w in ms:
    rows[h] += 1
    cols[w] += 1
    bombs[f"{h},{w}"] = True
rmax = max(rows)
cmax = max(cols)
rmax_hs = [i for i, v in enumerate(rows) if v == rmax]
cmax_wh = [i for i, v in enumerate(cols) if v == cmax]
for h, w in itertools.product(rmax_hs, cmax_wh):
    if f"{h},{w}" not in bombs:
        print((rmax + cmax))
        exit()
print((rmax + cmax - 1))

+import itertools -for m in ms: -    h = m[0] -    w = m[1] +for h, w in ms: -for h in rmax_hs: -    for w in cmax_wh: -        if f"{h},{w}" not in bombs: -            print((rmax + cmax)) -            exit() +for h, w in itertools.product(rmax_hs, cmax_wh): +    if f"{h},{w}" not in bombs: +        print((rmax + cmax)) +        exit()