from bisect import bisect_left

import sys

input = sys.stdin.readline

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

h = [0]*(H+1)

w = [0]*(W+1)

c = [[-1,10**6] for i in range(H+1)]

for i in range(m):

    a,b = list(map(int,input().split()))

    h[a] += 1

    w[b] += 1

    c[a].append(b)

mh = max(h)

mw = max(w)

hkouho = []

wkouho = []

for i in range(H+1):

    if h[i] == mh:

        hkouho.append(i)

for i in range(W+1):

    if w[i] == mw:

        wkouho.append(i)

for i in hkouho:

    c[i] = set(c[i])

    for j in wkouho:

        # if c[i][bisect_left(c[i],j)] != j:

        if j not in c[i]:

            print((mh+mw))

            exit()

print((mh+mw-1))
from bisect import bisect_left

import sys

input = sys.stdin.readline

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

h = [0]*(H+1)

w = [0]*(W+1)

c = [{-1,10**6} for i in range(H+1)]

for i in range(m):

    a,b = list(map(int,input().split()))

    h[a] += 1

    w[b] += 1

    c[a].add(b)

mh = max(h)

mw = max(w)

hkouho = []

wkouho = []

for i in range(H+1):

    if h[i] == mh:

        hkouho.append(i)

for i in range(W+1):

    if w[i] == mw:

        wkouho.append(i)

for i in hkouho:

    # c[i] = set(c[i])

    for j in wkouho:

        # if c[i][bisect_left(c[i],j)] != j:

        if j not in c[i]:

            print((mh+mw))

            exit()

print((mh+mw-1))
from bisect import bisect_left
import sys

input = sys.stdin.readline
H, W, m = list(map(int, input().split()))
h = [0] * (H + 1)
w = [0] * (W + 1)
c = [[-1, 10**6] for i in range(H + 1)]
for i in range(m):
    a, b = list(map(int, input().split()))
    h[a] += 1
    w[b] += 1
    c[a].append(b)
mh = max(h)
mw = max(w)
hkouho = []
wkouho = []
for i in range(H + 1):
    if h[i] == mh:
        hkouho.append(i)
for i in range(W + 1):
    if w[i] == mw:
        wkouho.append(i)
for i in hkouho:
    c[i] = set(c[i])
    for j in wkouho:
        # if c[i][bisect_left(c[i],j)] != j:
        if j not in c[i]:
            print((mh + mw))
            exit()
print((mh + mw - 1))

from bisect import bisect_left
import sys

input = sys.stdin.readline
H, W, m = list(map(int, input().split()))
h = [0] * (H + 1)
w = [0] * (W + 1)
c = [{-1, 10**6} for i in range(H + 1)]
for i in range(m):
    a, b = list(map(int, input().split()))
    h[a] += 1
    w[b] += 1
    c[a].add(b)
mh = max(h)
mw = max(w)
hkouho = []
wkouho = []
for i in range(H + 1):
    if h[i] == mh:
        hkouho.append(i)
for i in range(W + 1):
    if w[i] == mw:
        wkouho.append(i)
for i in hkouho:
    # c[i] = set(c[i])
    for j in wkouho:
        # if c[i][bisect_left(c[i],j)] != j:
        if j not in c[i]:
            print((mh + mw))
            exit()
print((mh + mw - 1))

-c = [[-1, 10**6] for i in range(H + 1)] +c = [{-1, 10**6} for i in range(H + 1)] -    c[a].append(b) +    c[a].add(b) -    c[i] = set(c[i]) +    # c[i] = set(c[i])