def main():
    H,W,M = map(int,input().split())
    row = [0 for i in range(H)]
    col = [0 for i in range(W)]
    target  = set()

    for _ in range(M):
        h,w = map(lambda x: int(x)-1,input().split())
        row[h] += 1
        col[w] += 1
        target.add((h,w))
    max_r = max(row)
    max_w = max(col)

    candidate_r = []
    for i,r in enumerate(row):
        if r == max_r:
            candidate_r.append(i)
    candidate_c = []
    for i,c in enumerate(col):
        if c == max_w:
            candidate_c.append(i)

    for idx_r in candidate_r:
        for idx_c in candidate_c:
            if (idx_r,idx_c) not in target:
                print(max_r+max_w)
                return
    print(max_r+max_w-1)
    return

if __name__ == '__main__':
    main() def main():
    H,W,M = map(int,input().split())
    row = [0 for i in range(H)]
    col = [0 for i in range(W)]
    target  = set()

    for _ in range(M):
        h,w = map(lambda x: int(x)-1,input().split())
        row[h] += 1
        col[w] += 1
        target.add((h,w))
    max_r = max(row)
    max_w = max(col)

    candidate_r = []
    for i,r in enumerate(row):
        if r == max_r:
            candidate_r.append(i)
    candidate_c = []
    for i,c in enumerate(col):
        if c == max_w:
            candidate_c.append(i)

    for idx_r in candidate_r:
        for idx_c in candidate_c:
            if (idx_r,idx_c) not in target:
                print(max_r+max_w)
                return
    print(max_r+max_w-1)
    return main H,W,M = map(int,input().split()) H map(int,input().split()) map int input().split() ().split () input split W M 0 for i in range(H) for i in range(H) i range(H) range H for i in range(H) 0 row = [0 for i in range(H)] row [0 for i in range(H)] 0 for i in range(W) for i in range(W) i range(W) range W for i in range(W) 0 col = [0 for i in range(W)] col [0 for i in range(W)] target  = set() target set() set for _ in range(M):
        h,w = map(lambda x: int(x)-1,input().split())
        row[h] += 1
        col[w] += 1
        target.add((h,w))
     _ range(M) range M h,w = map(lambda x: int(x)-1,input().split()) h map(lambda x: int(x)-1,input().split()) map lambda x: int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split w row[h] += 1 row[h] row h 1 col[w] += 1 col[w] col w 1 target.add((h,w)) target.add target add (h,w) h w max_r = max(row) max_r max(row) max row max_w = max(col) max_w max(col) max col candidate_r = [] candidate_r [] for i,r in enumerate(row):
        if r == max_r:
            candidate_r.append(i)
     i r enumerate(row) enumerate row if r == max_r:
            candidate_r.append(i)
     r == max_r r max_r candidate_r.append(i) candidate_r.append candidate_r append i candidate_c = [] candidate_c [] for i,c in enumerate(col):
        if c == max_w:
            candidate_c.append(i)

     i c enumerate(col) enumerate col if c == max_w:
            candidate_c.append(i)

     c == max_w c max_w candidate_c.append(i) candidate_c.append candidate_c append i for idx_r in candidate_r:
        for idx_c in candidate_c:
            if (idx_r,idx_c) not in target:
                print(max_r+max_w)
                return
     idx_r candidate_r for idx_c in candidate_c:
            if (idx_r,idx_c) not in target:
                print(max_r+max_w)
                return
     idx_c candidate_c if (idx_r,idx_c) not in target:
                print(max_r+max_w)
                return
     (idx_r,idx_c) not in target (idx_r,idx_c) idx_r idx_c target print(max_r+max_w) print max_r+max_w max_r max_w return print(max_r+max_w-1) print max_r+max_w-1 max_r+max_w max_r max_w 1 return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    H,W,M = map(int,input().split())
    row = [0 for i in range(H)]
    col = [0 for i in range(W)]
    target  = set()

    for _ in range(M):
        h,w = map(lambda x: int(x)-1,input().split())
        row[h] += 1
        col[w] += 1
        target.add((h,w))
    max_r = max(row)
    max_w = max(col)

    candidate_r = []
    for i,r in enumerate(row):
        if r == max_r:
            candidate_r.append(i)
    candidate_c = []
    for i,c in enumerate(col):
        if c == max_w:
            candidate_c.append(i)

    for idx_r in candidate_r:
        for idx_c in candidate_c:
            if (idx_r,idx_c) not in target:
                print(max_r+max_w)
                return
    print(max_r+max_w-1)
    return def main():
    H,W,M = map(int,input().split())
    row = [0 for i in range(H)]
    col = [0 for i in range(W)]
    target  = set()

    for _ in range(M):
        h,w = map(lambda x: int(x)-1,input().split())
        row[h] += 1
        col[w] += 1
        target.add((h,w))
    max_r = max(row)
    max_w = max(col)

    candidate_r = []
    for i,r in enumerate(row):
        if r == max_r:
            candidate_r.append(i)
    candidate_c = []
    for i,c in enumerate(col):
        if c == max_w:
            candidate_c.append(i)

    for idx_r in candidate_r:
        for idx_c in candidate_c:
            if (idx_r,idx_c) not in target:
                print(max_r+max_w)
                return
    print(max_r+max_w-1)
    return main
def main():
    H,W,M = map(int,input().split())
    row = [0 for i in range(H)]
    col = [0 for i in range(W)]
    target  = set()

    for _ in range(M):
        h,w = map(lambda x: int(x)-1,input().split())
        row[h] += 1
        col[w] += 1
        target.add((h,w))
    max_r = max(row)
    max_w = max(col)

    candidate_r = []
    for i,r in enumerate(row):
        if r == max_r:
            candidate_r.append(i)
    candidate_c = []
    for i,c in enumerate(col):
        if c == max_w:
            candidate_c.append(i)

    for idx_r in candidate_r:
        for idx_c in candidate_c:
            if (idx_r,idx_c) not in target:
                print(max_r+max_w)
                return
    print(max_r+max_w-1)
    return

if __name__ == '__main__':
    main()