def main():
    H, W, M = map(int, input().split())
    hw = [tuple(list(map(int, input().split()))) for _ in [0]*M]
    hw_set = set(hw)
    h_count = [0 for i in range(H+1)]
    w_count = [0 for i in range(W+1)]
    for h, w in hw:
        h_count[h] += 1
        w_count[w] += 1
    h_m = max(h_count)
    w_m = max(w_count)
    h_list = []
    w_list = []
    for i in range(H+1):
        if h_count[i] == h_m:
            h_list.append(i)
    for i in range(W+1):
        if w_count[i] == w_m:
            w_list.append(i)
    #print(h_list, w_list)
    for i in h_list:
        for j in w_list:
            if (i, j) not in hw_set:
                print(h_m+w_m)
                return
    print(h_m+w_m-1)


main() def main():
    H, W, M = map(int, input().split())
    hw = [tuple(list(map(int, input().split()))) for _ in [0]*M]
    hw_set = set(hw)
    h_count = [0 for i in range(H+1)]
    w_count = [0 for i in range(W+1)]
    for h, w in hw:
        h_count[h] += 1
        w_count[w] += 1
    h_m = max(h_count)
    w_m = max(w_count)
    h_list = []
    w_list = []
    for i in range(H+1):
        if h_count[i] == h_m:
            h_list.append(i)
    for i in range(W+1):
        if w_count[i] == w_m:
            w_list.append(i)
    #print(h_list, w_list)
    for i in h_list:
        for j in w_list:
            if (i, j) not in hw_set:
                print(h_m+w_m)
                return
    print(h_m+w_m-1) main H, W, M = map(int, input().split()) H map(int, input().split()) map int input().split() ().split () input split W M tuple(list(map(int, input().split()))) for _ in [0]*M for _ in [0]*M _ [0]*M [0] 0 M for _ in [0]*M tuple(list(map(int, input().split()))) tuple list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split hw = [tuple(list(map(int, input().split()))) for _ in [0]*M] hw [tuple(list(map(int, input().split()))) for _ in [0]*M] hw_set = set(hw) hw_set set(hw) set hw 0 for i in range(H+1) for i in range(H+1) i range(H+1) range H+1 H 1 for i in range(H+1) 0 h_count = [0 for i in range(H+1)] h_count [0 for i in range(H+1)] 0 for i in range(W+1) for i in range(W+1) i range(W+1) range W+1 W 1 for i in range(W+1) 0 w_count = [0 for i in range(W+1)] w_count [0 for i in range(W+1)] for h, w in hw:
        h_count[h] += 1
        w_count[w] += 1
     h w hw h_count[h] += 1 h_count[h] h_count h 1 w_count[w] += 1 w_count[w] w_count w 1 h_m = max(h_count) h_m max(h_count) max h_count w_m = max(w_count) w_m max(w_count) max w_count h_list = [] h_list [] w_list = [] w_list [] for i in range(H+1):
        if h_count[i] == h_m:
            h_list.append(i)
     i range(H+1) range H+1 H 1 if h_count[i] == h_m:
            h_list.append(i)
     h_count[i] == h_m h_count[i] h_count i h_m h_list.append(i) h_list.append h_list append i for i in range(W+1):
        if w_count[i] == w_m:
            w_list.append(i)
    #print(h_list, w_list)
     i range(W+1) range W+1 W 1 if w_count[i] == w_m:
            w_list.append(i)
    #print(h_list, w_list)
     w_count[i] == w_m w_count[i] w_count i w_m w_list.append(i) w_list.append w_list append i for i in h_list:
        for j in w_list:
            if (i, j) not in hw_set:
                print(h_m+w_m)
                return
     i h_list for j in w_list:
            if (i, j) not in hw_set:
                print(h_m+w_m)
                return
     j w_list if (i, j) not in hw_set:
                print(h_m+w_m)
                return
     (i, j) not in hw_set (i, j) i j hw_set print(h_m+w_m) print h_m+w_m h_m w_m return print(h_m+w_m-1) print h_m+w_m-1 h_m+w_m h_m w_m 1 main() main def main():
    H, W, M = map(int, input().split())
    hw = [tuple(list(map(int, input().split()))) for _ in [0]*M]
    hw_set = set(hw)
    h_count = [0 for i in range(H+1)]
    w_count = [0 for i in range(W+1)]
    for h, w in hw:
        h_count[h] += 1
        w_count[w] += 1
    h_m = max(h_count)
    w_m = max(w_count)
    h_list = []
    w_list = []
    for i in range(H+1):
        if h_count[i] == h_m:
            h_list.append(i)
    for i in range(W+1):
        if w_count[i] == w_m:
            w_list.append(i)
    #print(h_list, w_list)
    for i in h_list:
        for j in w_list:
            if (i, j) not in hw_set:
                print(h_m+w_m)
                return
    print(h_m+w_m-1) def main():
    H, W, M = map(int, input().split())
    hw = [tuple(list(map(int, input().split()))) for _ in [0]*M]
    hw_set = set(hw)
    h_count = [0 for i in range(H+1)]
    w_count = [0 for i in range(W+1)]
    for h, w in hw:
        h_count[h] += 1
        w_count[w] += 1
    h_m = max(h_count)
    w_m = max(w_count)
    h_list = []
    w_list = []
    for i in range(H+1):
        if h_count[i] == h_m:
            h_list.append(i)
    for i in range(W+1):
        if w_count[i] == w_m:
            w_list.append(i)
    #print(h_list, w_list)
    for i in h_list:
        for j in w_list:
            if (i, j) not in hw_set:
                print(h_m+w_m)
                return
    print(h_m+w_m-1) main
def main():
    H, W, M = map(int, input().split())
    hw = [tuple(list(map(int, input().split()))) for _ in [0]*M]
    hw_set = set(hw)
    h_count = [0 for i in range(H+1)]
    w_count = [0 for i in range(W+1)]
    for h, w in hw:
        h_count[h] += 1
        w_count[w] += 1
    h_m = max(h_count)
    w_m = max(w_count)
    h_list = []
    w_list = []
    for i in range(H+1):
        if h_count[i] == h_m:
            h_list.append(i)
    for i in range(W+1):
        if w_count[i] == w_m:
            w_list.append(i)
    #print(h_list, w_list)
    for i in h_list:
        for j in w_list:
            if (i, j) not in hw_set:
                print(h_m+w_m)
                return
    print(h_m+w_m-1)


main()
