import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

h,w,m = readints()

r = [0]*h
c = [0]*w

d = [set() for i in range(h)]
for i in range(m):
    a,b = (x-1 for x in readints())
    r[a] += 1
    c[b] += 1
    d[a].add(b)

mr = max(r)
mc = max(c)
R = [i for i,x in enumerate(r) if x==mr]
C = [i for i,x in enumerate(c) if x==mc]

flag = 1
if len(R)*len(C)>m:
    flag = 0
else:
    for x in R:
        for y in C:
            if y not in d[x]:
                flag = 0
                break

print(max(r)+max(c)-flag)



 import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline def readstr():return readline().rstrip().decode() readstr def readstrs():return list(readline().decode().split()) readstrs def readint():return int(readline()) readint def readints():return list(map(int,readline().split())) readints def printrows(x):print('\n'.join(map(str,x))) printrows x x def printline(x):print(' '.join(map(str,x))) printline x x h,w,m = readints() h readints() readints w m r = [0]*h r [0]*h [0] 0 h c = [0]*w c [0]*w [0] 0 w set() for i in range(h) for i in range(h) i range(h) range h for i in range(h) set() set d = [set() for i in range(h)] d [set() for i in range(h)] for i in range(m):
    a,b = (x-1 for x in readints())
    r[a] += 1
    c[b] += 1
    d[a].add(b) i range(m) range m x-1 for x in readints() for x in readints() x readints() readints for x in readints() x-1 x 1 a,b = (x-1 for x in readints()) a (x-1 for x in readints()) b r[a] += 1 r[a] r a 1 c[b] += 1 c[b] c b 1 d[a].add(b) [a].add [a] d a add b mr = max(r) mr max(r) max r mc = max(c) mc max(c) max c i for i,x in enumerate(r) if x==mr for i,x in enumerate(r) if x==mr i x enumerate(r) enumerate r x==mr x mr if x==mr i R = [i for i,x in enumerate(r) if x==mr] R [i for i,x in enumerate(r) if x==mr] i for i,x in enumerate(c) if x==mc for i,x in enumerate(c) if x==mc i x enumerate(c) enumerate c x==mc x mc if x==mc i C = [i for i,x in enumerate(c) if x==mc] C [i for i,x in enumerate(c) if x==mc] flag = 1 flag 1 if len(R)*len(C)>m:
    flag = 0
else:
    for x in R:
        for y in C:
            if y not in d[x]:
                flag = 0
                break len(R)*len(C)>m len(R)*len(C) len(R) len R len(C) len C m flag = 0 flag 0 for x in R:
        for y in C:
            if y not in d[x]:
                flag = 0
                break x R for y in C:
            if y not in d[x]:
                flag = 0
                break y C if y not in d[x]:
                flag = 0
                break y not in d[x] y d[x] d x flag = 0 flag 0 break print(max(r)+max(c)-flag) print max(r)+max(c)-flag max(r)+max(c) max(r) max r max(c) max c flag readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline flag = 1 1 flag C = [i for i,x in enumerate(c) if x==mc] [i for i,x in enumerate(c) if x==mc] C flag = 0 0 flag h,w,m = readints() readints() h def readstr():return readline().rstrip().decode() def readstr():return readline().rstrip().decode() readstr flag = 0 0 flag b = (x-1 for x in readints()) (x-1 for x in readints()) b def readstrs():return list(readline().decode().split()) def readstrs():return list(readline().decode().split()) readstrs d = [set() for i in range(h)] [set() for i in range(h)] d w,m = readints() readints() w m = readints() readints() m def printline(x):print(' '.join(map(str,x))) def printline(x):print(' '.join(map(str,x))) printline def readint():return int(readline()) def readint():return int(readline()) readint a,b = (x-1 for x in readints()) (x-1 for x in readints()) a mr = max(r) max(r) mr def printrows(x):print('\n'.join(map(str,x))) def printrows(x):print('\n'.join(map(str,x))) printrows c = [0]*w [0]*w c mc = max(c) max(c) mc def readints():return list(map(int,readline().split())) def readints():return list(map(int,readline().split())) readints r = [0]*h [0]*h r R = [i for i,x in enumerate(r) if x==mr] [i for i,x in enumerate(r) if x==mr] R
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

h,w,m = readints()

r = [0]*h
c = [0]*w

d = [set() for i in range(h)]
for i in range(m):
    a,b = (x-1 for x in readints())
    r[a] += 1
    c[b] += 1
    d[a].add(b)

mr = max(r)
mc = max(c)
R = [i for i,x in enumerate(r) if x==mr]
C = [i for i,x in enumerate(c) if x==mc]

flag = 1
if len(R)*len(C)>m:
    flag = 0
else:
    for x in R:
        for y in C:
            if y not in d[x]:
                flag = 0
                break

print(max(r)+max(c)-flag)




