import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0


H,W,M = map(int,readline().split())

col = [0]*W
row = [0]*H
elements = []
for i in range(M):
    h,w = map(int,readline().split())
    h,w = h-1,w-1
    elements.append((h,w))
    col[w] += 1
    row[h] += 1

def rank(lst,syoujun=False):
    res2 = list(set(lst))
    ans = []
    if syoujun:
        res2.sort()
    else:
        res2.sort(reverse=True)
    dic1 = dict()
    for i in range(len(res2)):
        dic1[res2[i]] = i
    for i in lst:
        #ans.append(dic1[i]) #zero-indexed
        ans.append(dic1[i] + 1) #one-indexed
    
    return ans

col2 = rank(col)
row2 = rank(row)

cmax = col2.count(1)
rmax = row2.count(1)

counter = 0
for i,j in elements:
    if col2[j] == 1 and row2[i] == 1:
        counter += 1

if counter == cmax*rmax:
    print(max(col) + max(row)-1)
else:
    print(max(col) + max(row)) import sys sys readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline def even(n): return 1 if n%2==0 else 0 even n n H,W,M = map(int,readline().split()) H map(int,readline().split()) map int readline().split() ().split () readline split W M col = [0]*W col [0]*W [0] 0 W row = [0]*H row [0]*H [0] 0 H elements = [] elements [] for i in range(M):
    h,w = map(int,readline().split())
    h,w = h-1,w-1
    elements.append((h,w))
    col[w] += 1
    row[h] += 1 i range(M) range M h,w = map(int,readline().split()) h map(int,readline().split()) map int readline().split() ().split () readline split w h,w = h-1,w-1 h h-1 h 1 w w-1 w 1 elements.append((h,w)) elements.append elements append (h,w) h w col[w] += 1 col[w] col w 1 row[h] += 1 row[h] row h 1 def rank(lst,syoujun=False):
    res2 = list(set(lst))
    ans = []
    if syoujun:
        res2.sort()
    else:
        res2.sort(reverse=True)
    dic1 = dict()
    for i in range(len(res2)):
        dic1[res2[i]] = i
    for i in lst:
        #ans.append(dic1[i]) #zero-indexed
        ans.append(dic1[i] + 1) #one-indexed
    
    return ans rank res2 = list(set(lst)) res2 list(set(lst)) list set(lst) set lst ans = [] ans [] if syoujun:
        res2.sort()
    else:
        res2.sort(reverse=True)
     syoujun res2.sort() res2.sort res2 sort res2.sort(reverse=True) res2.sort res2 sort reverse=True reverse True dic1 = dict() dic1 dict() dict for i in range(len(res2)):
        dic1[res2[i]] = i
     i range(len(res2)) range len(res2) len res2 dic1[res2[i]] = i dic1[res2[i]] dic1 res2[i] res2 i i for i in lst:
        #ans.append(dic1[i]) #zero-indexed
        ans.append(dic1[i] + 1) #one-indexed
    
     i lst ans.append(dic1[i] + 1) ans.append ans append dic1[i] + 1 dic1[i] dic1 i 1 return ans ans lst lst syoujun=False syoujun False col2 = rank(col) col2 rank(col) rank col row2 = rank(row) row2 rank(row) rank row cmax = col2.count(1) cmax col2.count(1) col2.count col2 count 1 rmax = row2.count(1) rmax row2.count(1) row2.count row2 count 1 counter = 0 counter 0 for i,j in elements:
    if col2[j] == 1 and row2[i] == 1:
        counter += 1 i j elements if col2[j] == 1 and row2[i] == 1:
        counter += 1 col2[j] == 1 and row2[i] == 1 col2[j] == 1 col2[j] col2 j 1 row2[i] == 1 row2[i] row2 i 1 counter += 1 counter 1 if counter == cmax*rmax:
    print(max(col) + max(row)-1)
else:
    print(max(col) + max(row)) counter == cmax*rmax counter cmax*rmax cmax rmax print(max(col) + max(row)-1) print max(col) + max(row)-1 max(col) + max(row) max(col) max col max(row) max row 1 print(max(col) + max(row)) print max(col) + max(row) max(col) max col max(row) max row h,w = map(int,readline().split()) map(int,readline().split()) h w = map(int,readline().split()) map(int,readline().split()) w col2 = rank(col) rank(col) col2 W,M = map(int,readline().split()) map(int,readline().split()) W row = [0]*H [0]*H row w = h-1,w-1 w-1 w rmax = row2.count(1) row2.count(1) rmax M = map(int,readline().split()) map(int,readline().split()) M row2 = rank(row) rank(row) row2 counter = 0 0 counter readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline H,W,M = map(int,readline().split()) map(int,readline().split()) H h,w = h-1,w-1 h-1 h def even(n): return 1 if n%2==0 else 0 def even(n): return 1 if n%2==0 else 0 even cmax = col2.count(1) col2.count(1) cmax elements = [] [] elements counter += 1 1 counter col = [0]*W [0]*W col def rank(lst,syoujun=False):
    res2 = list(set(lst))
    ans = []
    if syoujun:
        res2.sort()
    else:
        res2.sort(reverse=True)
    dic1 = dict()
    for i in range(len(res2)):
        dic1[res2[i]] = i
    for i in lst:
        #ans.append(dic1[i]) #zero-indexed
        ans.append(dic1[i] + 1) #one-indexed
    
    return ans def rank(lst,syoujun=False):
    res2 = list(set(lst))
    ans = []
    if syoujun:
        res2.sort()
    else:
        res2.sort(reverse=True)
    dic1 = dict()
    for i in range(len(res2)):
        dic1[res2[i]] = i
    for i in lst:
        #ans.append(dic1[i]) #zero-indexed
        ans.append(dic1[i] + 1) #one-indexed
    
    return ans rank
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0


H,W,M = map(int,readline().split())

col = [0]*W
row = [0]*H
elements = []
for i in range(M):
    h,w = map(int,readline().split())
    h,w = h-1,w-1
    elements.append((h,w))
    col[w] += 1
    row[h] += 1

def rank(lst,syoujun=False):
    res2 = list(set(lst))
    ans = []
    if syoujun:
        res2.sort()
    else:
        res2.sort(reverse=True)
    dic1 = dict()
    for i in range(len(res2)):
        dic1[res2[i]] = i
    for i in lst:
        #ans.append(dic1[i]) #zero-indexed
        ans.append(dic1[i] + 1) #one-indexed
    
    return ans

col2 = rank(col)
row2 = rank(row)

cmax = col2.count(1)
rmax = row2.count(1)

counter = 0
for i,j in elements:
    if col2[j] == 1 and row2[i] == 1:
        counter += 1

if counter == cmax*rmax:
    print(max(col) + max(row)-1)
else:
    print(max(col) + max(row))