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)))

import bisect
from operator import itemgetter

h,w,m = readints()

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

p = [readints() for i in range(m)]
p.sort(key=itemgetter(1))

d = [[] for i in range(h)]
for i in range(m):
    a,b = (x-1 for x in p[i])
    r[a] += 1
    c[b] += 1
    d[a].append(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:
            z = bisect.bisect_left(d[x],y)
            if z>=len(d[x]):
                flag = 0
                break
            else:
                if y != d[x][z]:
                    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 import bisect bisect from operator import itemgetter 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 readints() for i in range(m) for i in range(m) i range(m) range m for i in range(m) readints() readints p = [readints() for i in range(m)] p [readints() for i in range(m)] p.sort(key=itemgetter(1)) p.sort p sort key=itemgetter(1) key itemgetter(1) itemgetter 1 [] for i in range(h) for i in range(h) i range(h) range h for i in range(h) [] d = [[] for i in range(h)] d [[] for i in range(h)] for i in range(m):
    a,b = (x-1 for x in p[i])
    r[a] += 1
    c[b] += 1
    d[a].append(b) i range(m) range m x-1 for x in p[i] for x in p[i] x p[i] p i for x in p[i] x-1 x 1 a,b = (x-1 for x in p[i]) a (x-1 for x in p[i]) b r[a] += 1 r[a] r a 1 c[b] += 1 c[b] c b 1 d[a].append(b) [a].append [a] d a append 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:
            z = bisect.bisect_left(d[x],y)
            if z>=len(d[x]):
                flag = 0
                break
            else:
                if y != d[x][z]:
                    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:
            z = bisect.bisect_left(d[x],y)
            if z>=len(d[x]):
                flag = 0
                break
            else:
                if y != d[x][z]:
                    flag = 0
                    break x R for y in C:
            z = bisect.bisect_left(d[x],y)
            if z>=len(d[x]):
                flag = 0
                break
            else:
                if y != d[x][z]:
                    flag = 0
                    break y C z = bisect.bisect_left(d[x],y) z bisect.bisect_left(d[x],y) bisect.bisect_left bisect bisect_left d[x] d x y if z>=len(d[x]):
                flag = 0
                break
            else:
                if y != d[x][z]:
                    flag = 0
                    break z>=len(d[x]) z len(d[x]) len d[x] d x flag = 0 flag 0 break if y != d[x][z]:
                    flag = 0
                    break y != d[x][z] y d[x][z] [x] d x z 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 R = [i for i,x in enumerate(r) if x==mr] [i for i,x in enumerate(r) if x==mr] R m = readints() readints() m def readstr():return readline().rstrip().decode() def readstr():return readline().rstrip().decode() readstr flag = 0 0 flag flag = 0 0 flag z = bisect.bisect_left(d[x],y) bisect.bisect_left(d[x],y) z readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline def printrows(x):print('\n'.join(map(str,x))) def printrows(x):print('\n'.join(map(str,x))) printrows def readstrs():return list(readline().decode().split()) def readstrs():return list(readline().decode().split()) readstrs p = [readints() for i in range(m)] [readints() for i in range(m)] p mc = max(c) max(c) mc r = [0]*h [0]*h r def readints():return list(map(int,readline().split())) def readints():return list(map(int,readline().split())) readints C = [i for i,x in enumerate(c) if x==mc] [i for i,x in enumerate(c) if x==mc] C h,w,m = readints() readints() h def readint():return int(readline()) def readint():return int(readline()) readint def printline(x):print(' '.join(map(str,x))) def printline(x):print(' '.join(map(str,x))) printline flag = 0 0 flag flag = 1 1 flag w,m = readints() readints() w c = [0]*w [0]*w c mr = max(r) max(r) mr d = [[] for i in range(h)] [[] for i in range(h)] d a,b = (x-1 for x in p[i]) (x-1 for x in p[i]) a b = (x-1 for x in p[i]) (x-1 for x in p[i]) b
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)))

import bisect
from operator import itemgetter

h,w,m = readints()

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

p = [readints() for i in range(m)]
p.sort(key=itemgetter(1))

d = [[] for i in range(h)]
for i in range(m):
    a,b = (x-1 for x in p[i])
    r[a] += 1
    c[b] += 1
    d[a].append(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:
            z = bisect.bisect_left(d[x],y)
            if z>=len(d[x]):
                flag = 0
                break
            else:
                if y != d[x][z]:
                    flag = 0
                    break

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




