def main():
    H,W,M = map(int,input().split())
    s = []
    h_cnt = [0 for i in range(H)]
    w_cnt = [0 for i in range(W)]
    for i in range(M):
        h,w = map(int,input().split())
        s.append([h-1,w-1])
        h_cnt[h-1] += 1
        w_cnt[w-1] += 1
    h_m,w_m = max(h_cnt), max(w_cnt)
    h_mp,w_mp = [],[]
    for i in range(H):
        if h_cnt[i] == h_m:
            h_mp.append(i)
    for i in range(W):
        if w_cnt[i] == w_m:
            w_mp.append(i)
    f = 0
    for i in range(M):
        if h_cnt[s[i][0]] == h_m and w_cnt[s[i][1]] == w_m:
            f += 1
    if len(w_mp)*len(h_mp)-f<1:
        print(h_m+w_m-1)
    else:
        print(h_m+w_m)

if __name__ == "__main__":
    main() def main():
    H,W,M = map(int,input().split())
    s = []
    h_cnt = [0 for i in range(H)]
    w_cnt = [0 for i in range(W)]
    for i in range(M):
        h,w = map(int,input().split())
        s.append([h-1,w-1])
        h_cnt[h-1] += 1
        w_cnt[w-1] += 1
    h_m,w_m = max(h_cnt), max(w_cnt)
    h_mp,w_mp = [],[]
    for i in range(H):
        if h_cnt[i] == h_m:
            h_mp.append(i)
    for i in range(W):
        if w_cnt[i] == w_m:
            w_mp.append(i)
    f = 0
    for i in range(M):
        if h_cnt[s[i][0]] == h_m and w_cnt[s[i][1]] == w_m:
            f += 1
    if len(w_mp)*len(h_mp)-f<1:
        print(h_m+w_m-1)
    else:
        print(h_m+w_m) main H,W,M = map(int,input().split()) H map(int,input().split()) map int input().split() ().split () input split W M s = [] s [] 0 for i in range(H) for i in range(H) i range(H) range H for i in range(H) 0 h_cnt = [0 for i in range(H)] h_cnt [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 w_cnt = [0 for i in range(W)] w_cnt [0 for i in range(W)] for i in range(M):
        h,w = map(int,input().split())
        s.append([h-1,w-1])
        h_cnt[h-1] += 1
        w_cnt[w-1] += 1
     i range(M) range M h,w = map(int,input().split()) h map(int,input().split()) map int input().split() ().split () input split w s.append([h-1,w-1]) s.append s append [h-1,w-1] h-1 h 1 w-1 w 1 h_cnt[h-1] += 1 h_cnt[h-1] h_cnt h-1 h 1 1 w_cnt[w-1] += 1 w_cnt[w-1] w_cnt w-1 w 1 1 h_m,w_m = max(h_cnt), max(w_cnt) h_m max(h_cnt) max h_cnt w_m max(w_cnt) max w_cnt h_mp,w_mp = [],[] h_mp [] w_mp [] for i in range(H):
        if h_cnt[i] == h_m:
            h_mp.append(i)
     i range(H) range H if h_cnt[i] == h_m:
            h_mp.append(i)
     h_cnt[i] == h_m h_cnt[i] h_cnt i h_m h_mp.append(i) h_mp.append h_mp append i for i in range(W):
        if w_cnt[i] == w_m:
            w_mp.append(i)
     i range(W) range W if w_cnt[i] == w_m:
            w_mp.append(i)
     w_cnt[i] == w_m w_cnt[i] w_cnt i w_m w_mp.append(i) w_mp.append w_mp append i f = 0 f 0 for i in range(M):
        if h_cnt[s[i][0]] == h_m and w_cnt[s[i][1]] == w_m:
            f += 1
     i range(M) range M if h_cnt[s[i][0]] == h_m and w_cnt[s[i][1]] == w_m:
            f += 1
     h_cnt[s[i][0]] == h_m and w_cnt[s[i][1]] == w_m h_cnt[s[i][0]] == h_m h_cnt[s[i][0]] h_cnt s[i][0] [i] s i 0 h_m w_cnt[s[i][1]] == w_m w_cnt[s[i][1]] w_cnt s[i][1] [i] s i 1 w_m f += 1 f 1 if len(w_mp)*len(h_mp)-f<1:
        print(h_m+w_m-1)
    else:
        print(h_m+w_m) len(w_mp)*len(h_mp)-f<1 len(w_mp)*len(h_mp)-f len(w_mp)*len(h_mp) len(w_mp) len w_mp len(h_mp) len h_mp f 1 print(h_m+w_m-1) print h_m+w_m-1 h_m+w_m h_m w_m 1 print(h_m+w_m) print h_m+w_m h_m w_m if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    H,W,M = map(int,input().split())
    s = []
    h_cnt = [0 for i in range(H)]
    w_cnt = [0 for i in range(W)]
    for i in range(M):
        h,w = map(int,input().split())
        s.append([h-1,w-1])
        h_cnt[h-1] += 1
        w_cnt[w-1] += 1
    h_m,w_m = max(h_cnt), max(w_cnt)
    h_mp,w_mp = [],[]
    for i in range(H):
        if h_cnt[i] == h_m:
            h_mp.append(i)
    for i in range(W):
        if w_cnt[i] == w_m:
            w_mp.append(i)
    f = 0
    for i in range(M):
        if h_cnt[s[i][0]] == h_m and w_cnt[s[i][1]] == w_m:
            f += 1
    if len(w_mp)*len(h_mp)-f<1:
        print(h_m+w_m-1)
    else:
        print(h_m+w_m) def main():
    H,W,M = map(int,input().split())
    s = []
    h_cnt = [0 for i in range(H)]
    w_cnt = [0 for i in range(W)]
    for i in range(M):
        h,w = map(int,input().split())
        s.append([h-1,w-1])
        h_cnt[h-1] += 1
        w_cnt[w-1] += 1
    h_m,w_m = max(h_cnt), max(w_cnt)
    h_mp,w_mp = [],[]
    for i in range(H):
        if h_cnt[i] == h_m:
            h_mp.append(i)
    for i in range(W):
        if w_cnt[i] == w_m:
            w_mp.append(i)
    f = 0
    for i in range(M):
        if h_cnt[s[i][0]] == h_m and w_cnt[s[i][1]] == w_m:
            f += 1
    if len(w_mp)*len(h_mp)-f<1:
        print(h_m+w_m-1)
    else:
        print(h_m+w_m) main
def main():
    H,W,M = map(int,input().split())
    s = []
    h_cnt = [0 for i in range(H)]
    w_cnt = [0 for i in range(W)]
    for i in range(M):
        h,w = map(int,input().split())
        s.append([h-1,w-1])
        h_cnt[h-1] += 1
        w_cnt[w-1] += 1
    h_m,w_m = max(h_cnt), max(w_cnt)
    h_mp,w_mp = [],[]
    for i in range(H):
        if h_cnt[i] == h_m:
            h_mp.append(i)
    for i in range(W):
        if w_cnt[i] == w_m:
            w_mp.append(i)
    f = 0
    for i in range(M):
        if h_cnt[s[i][0]] == h_m and w_cnt[s[i][1]] == w_m:
            f += 1
    if len(w_mp)*len(h_mp)-f<1:
        print(h_m+w_m-1)
    else:
        print(h_m+w_m)

if __name__ == "__main__":
    main()
