def main():
    h, w, m = map(int, input().split())
    mapa = {}
    strings = [0]*h
    rows = [0]*w
    for _ in range(m):
        h1, w1 = map(int, input().split())
        if not mapa.get(h1-1, 0):
            mapa[h1-1] = []
        mapa[h1-1].append(w1-1)
        strings[h1-1] += 1
        rows[w1-1] += 1
    
    max_s = max(strings)
    max_r = max(rows)
    strings_max = []
    rows_max = []
    for i in range(h):
        if strings[i] == max_s:
            strings_max.append(i)
    for i in range(w):
        if rows[i] == max_r:
            rows_max.append(i)
    
    forbidden_positions = set(mapa[strings_max[0]])
    for item in strings_max[1:]:
        forbidden_positions.intersection_update(set(mapa[item]))

    answer_set = set(rows_max).difference(forbidden_positions)
    if answer_set:
        print(max_s + max_r)
    else:
        print(max_s + max_r - 1)

main() def main():
    h, w, m = map(int, input().split())
    mapa = {}
    strings = [0]*h
    rows = [0]*w
    for _ in range(m):
        h1, w1 = map(int, input().split())
        if not mapa.get(h1-1, 0):
            mapa[h1-1] = []
        mapa[h1-1].append(w1-1)
        strings[h1-1] += 1
        rows[w1-1] += 1
    
    max_s = max(strings)
    max_r = max(rows)
    strings_max = []
    rows_max = []
    for i in range(h):
        if strings[i] == max_s:
            strings_max.append(i)
    for i in range(w):
        if rows[i] == max_r:
            rows_max.append(i)
    
    forbidden_positions = set(mapa[strings_max[0]])
    for item in strings_max[1:]:
        forbidden_positions.intersection_update(set(mapa[item]))

    answer_set = set(rows_max).difference(forbidden_positions)
    if answer_set:
        print(max_s + max_r)
    else:
        print(max_s + max_r - 1) main h, w, m = map(int, input().split()) h map(int, input().split()) map int input().split() ().split () input split w m mapa = {} mapa {} strings = [0]*h strings [0]*h [0] 0 h rows = [0]*w rows [0]*w [0] 0 w for _ in range(m):
        h1, w1 = map(int, input().split())
        if not mapa.get(h1-1, 0):
            mapa[h1-1] = []
        mapa[h1-1].append(w1-1)
        strings[h1-1] += 1
        rows[w1-1] += 1
    
     _ range(m) range m h1, w1 = map(int, input().split()) h1 map(int, input().split()) map int input().split() ().split () input split w1 if not mapa.get(h1-1, 0):
            mapa[h1-1] = []
         not mapa.get(h1-1, 0) mapa.get(h1-1, 0) mapa.get mapa get h1-1 h1 1 0 mapa[h1-1] = [] mapa[h1-1] mapa h1-1 h1 1 [] mapa[h1-1].append(w1-1) [h1-1].append [h1-1] mapa h1-1 h1 1 append w1-1 w1 1 strings[h1-1] += 1 strings[h1-1] strings h1-1 h1 1 1 rows[w1-1] += 1 rows[w1-1] rows w1-1 w1 1 1 max_s = max(strings) max_s max(strings) max strings max_r = max(rows) max_r max(rows) max rows strings_max = [] strings_max [] rows_max = [] rows_max [] for i in range(h):
        if strings[i] == max_s:
            strings_max.append(i)
     i range(h) range h if strings[i] == max_s:
            strings_max.append(i)
     strings[i] == max_s strings[i] strings i max_s strings_max.append(i) strings_max.append strings_max append i for i in range(w):
        if rows[i] == max_r:
            rows_max.append(i)
    
     i range(w) range w if rows[i] == max_r:
            rows_max.append(i)
    
     rows[i] == max_r rows[i] rows i max_r rows_max.append(i) rows_max.append rows_max append i forbidden_positions = set(mapa[strings_max[0]]) forbidden_positions set(mapa[strings_max[0]]) set mapa[strings_max[0]] mapa strings_max[0] strings_max 0 for item in strings_max[1:]:
        forbidden_positions.intersection_update(set(mapa[item]))

     item strings_max[1:] strings_max 1: 1 forbidden_positions.intersection_update(set(mapa[item])) forbidden_positions.intersection_update forbidden_positions intersection_update set(mapa[item]) set mapa[item] mapa item answer_set = set(rows_max).difference(forbidden_positions) answer_set set(rows_max).difference(forbidden_positions) (rows_max).difference (rows_max) set rows_max difference forbidden_positions if answer_set:
        print(max_s + max_r)
    else:
        print(max_s + max_r - 1) answer_set print(max_s + max_r) print max_s + max_r max_s max_r print(max_s + max_r - 1) print max_s + max_r - 1 max_s + max_r max_s max_r 1 main() main def main():
    h, w, m = map(int, input().split())
    mapa = {}
    strings = [0]*h
    rows = [0]*w
    for _ in range(m):
        h1, w1 = map(int, input().split())
        if not mapa.get(h1-1, 0):
            mapa[h1-1] = []
        mapa[h1-1].append(w1-1)
        strings[h1-1] += 1
        rows[w1-1] += 1
    
    max_s = max(strings)
    max_r = max(rows)
    strings_max = []
    rows_max = []
    for i in range(h):
        if strings[i] == max_s:
            strings_max.append(i)
    for i in range(w):
        if rows[i] == max_r:
            rows_max.append(i)
    
    forbidden_positions = set(mapa[strings_max[0]])
    for item in strings_max[1:]:
        forbidden_positions.intersection_update(set(mapa[item]))

    answer_set = set(rows_max).difference(forbidden_positions)
    if answer_set:
        print(max_s + max_r)
    else:
        print(max_s + max_r - 1) def main():
    h, w, m = map(int, input().split())
    mapa = {}
    strings = [0]*h
    rows = [0]*w
    for _ in range(m):
        h1, w1 = map(int, input().split())
        if not mapa.get(h1-1, 0):
            mapa[h1-1] = []
        mapa[h1-1].append(w1-1)
        strings[h1-1] += 1
        rows[w1-1] += 1
    
    max_s = max(strings)
    max_r = max(rows)
    strings_max = []
    rows_max = []
    for i in range(h):
        if strings[i] == max_s:
            strings_max.append(i)
    for i in range(w):
        if rows[i] == max_r:
            rows_max.append(i)
    
    forbidden_positions = set(mapa[strings_max[0]])
    for item in strings_max[1:]:
        forbidden_positions.intersection_update(set(mapa[item]))

    answer_set = set(rows_max).difference(forbidden_positions)
    if answer_set:
        print(max_s + max_r)
    else:
        print(max_s + max_r - 1) main
def main():
    h, w, m = map(int, input().split())
    mapa = {}
    strings = [0]*h
    rows = [0]*w
    for _ in range(m):
        h1, w1 = map(int, input().split())
        if not mapa.get(h1-1, 0):
            mapa[h1-1] = []
        mapa[h1-1].append(w1-1)
        strings[h1-1] += 1
        rows[w1-1] += 1
    
    max_s = max(strings)
    max_r = max(rows)
    strings_max = []
    rows_max = []
    for i in range(h):
        if strings[i] == max_s:
            strings_max.append(i)
    for i in range(w):
        if rows[i] == max_r:
            rows_max.append(i)
    
    forbidden_positions = set(mapa[strings_max[0]])
    for item in strings_max[1:]:
        forbidden_positions.intersection_update(set(mapa[item]))

    answer_set = set(rows_max).difference(forbidden_positions)
    if answer_set:
        print(max_s + max_r)
    else:
        print(max_s + max_r - 1)

main()
