def resolve():
    H, W, M = map(int, input().split())
    pos = []
    for _ in range(M):
        pos.append(list(map(int, input().split())))

    h_totals = [0] * (H+1)
    w_totals = [0] * (W+1)
    overlap = [set() for _ in range(H+1)]

    for ph, pw in pos:
        h_totals[ph] += 1
        w_totals[pw] += 1
        overlap[ph].add(pw)

    max_h = -1
    max_w = -1
    h_list = []
    w_list = []
    for i in range(1, H+1):
        if h_totals[i] > max_h:
            max_h = h_totals[i]
            h_list = [i]
        elif h_totals[i] == max_h:
            h_list.append(i)
    for j in range(1, W+1):
        if w_totals[j] > max_w:
            max_w = w_totals[j]
            w_list = [j]
        elif w_totals[j] == max_w:
            w_list.append(j)

    for i in h_list:
        for j in w_list:
            if j not in overlap[i]:
                print(max_h + max_w)
                return
    print(max_h + max_w - 1)

if __name__ == "__main__":
    resolve() def resolve():
    H, W, M = map(int, input().split())
    pos = []
    for _ in range(M):
        pos.append(list(map(int, input().split())))

    h_totals = [0] * (H+1)
    w_totals = [0] * (W+1)
    overlap = [set() for _ in range(H+1)]

    for ph, pw in pos:
        h_totals[ph] += 1
        w_totals[pw] += 1
        overlap[ph].add(pw)

    max_h = -1
    max_w = -1
    h_list = []
    w_list = []
    for i in range(1, H+1):
        if h_totals[i] > max_h:
            max_h = h_totals[i]
            h_list = [i]
        elif h_totals[i] == max_h:
            h_list.append(i)
    for j in range(1, W+1):
        if w_totals[j] > max_w:
            max_w = w_totals[j]
            w_list = [j]
        elif w_totals[j] == max_w:
            w_list.append(j)

    for i in h_list:
        for j in w_list:
            if j not in overlap[i]:
                print(max_h + max_w)
                return
    print(max_h + max_w - 1) resolve H, W, M = map(int, input().split()) H map(int, input().split()) map int input().split() ().split () input split W M pos = [] pos [] for _ in range(M):
        pos.append(list(map(int, input().split())))

     _ range(M) range M pos.append(list(map(int, input().split()))) pos.append pos append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split h_totals = [0] * (H+1) h_totals [0] * (H+1) [0] 0 H+1 H 1 w_totals = [0] * (W+1) w_totals [0] * (W+1) [0] 0 W+1 W 1 set() for _ in range(H+1) for _ in range(H+1) _ range(H+1) range H+1 H 1 for _ in range(H+1) set() set overlap = [set() for _ in range(H+1)] overlap [set() for _ in range(H+1)] for ph, pw in pos:
        h_totals[ph] += 1
        w_totals[pw] += 1
        overlap[ph].add(pw)

     ph pw pos h_totals[ph] += 1 h_totals[ph] h_totals ph 1 w_totals[pw] += 1 w_totals[pw] w_totals pw 1 overlap[ph].add(pw) [ph].add [ph] overlap ph add pw max_h = -1 max_h -1 max_w = -1 max_w -1 h_list = [] h_list [] w_list = [] w_list [] for i in range(1, H+1):
        if h_totals[i] > max_h:
            max_h = h_totals[i]
            h_list = [i]
        elif h_totals[i] == max_h:
            h_list.append(i)
     i range(1, H+1) range 1 H+1 H 1 if h_totals[i] > max_h:
            max_h = h_totals[i]
            h_list = [i]
        elif h_totals[i] == max_h:
            h_list.append(i)
     h_totals[i] > max_h h_totals[i] h_totals i max_h max_h = h_totals[i] max_h h_totals[i] h_totals i h_list = [i] h_list [i] i elif h_totals[i] == max_h:
            h_list.append(i)
     h_totals[i] == max_h h_totals[i] h_totals i max_h h_list.append(i) h_list.append h_list append i for j in range(1, W+1):
        if w_totals[j] > max_w:
            max_w = w_totals[j]
            w_list = [j]
        elif w_totals[j] == max_w:
            w_list.append(j)

     j range(1, W+1) range 1 W+1 W 1 if w_totals[j] > max_w:
            max_w = w_totals[j]
            w_list = [j]
        elif w_totals[j] == max_w:
            w_list.append(j)

     w_totals[j] > max_w w_totals[j] w_totals j max_w max_w = w_totals[j] max_w w_totals[j] w_totals j w_list = [j] w_list [j] j elif w_totals[j] == max_w:
            w_list.append(j)

     w_totals[j] == max_w w_totals[j] w_totals j max_w w_list.append(j) w_list.append w_list append j for i in h_list:
        for j in w_list:
            if j not in overlap[i]:
                print(max_h + max_w)
                return
     i h_list for j in w_list:
            if j not in overlap[i]:
                print(max_h + max_w)
                return
     j w_list if j not in overlap[i]:
                print(max_h + max_w)
                return
     j not in overlap[i] j overlap[i] overlap i print(max_h + max_w) print max_h + max_w max_h max_w return print(max_h + max_w - 1) print max_h + max_w - 1 max_h + max_w max_h max_w 1 if __name__ == "__main__":
    resolve() __name__ == "__main__" __name__ "__main__" resolve() resolve def resolve():
    H, W, M = map(int, input().split())
    pos = []
    for _ in range(M):
        pos.append(list(map(int, input().split())))

    h_totals = [0] * (H+1)
    w_totals = [0] * (W+1)
    overlap = [set() for _ in range(H+1)]

    for ph, pw in pos:
        h_totals[ph] += 1
        w_totals[pw] += 1
        overlap[ph].add(pw)

    max_h = -1
    max_w = -1
    h_list = []
    w_list = []
    for i in range(1, H+1):
        if h_totals[i] > max_h:
            max_h = h_totals[i]
            h_list = [i]
        elif h_totals[i] == max_h:
            h_list.append(i)
    for j in range(1, W+1):
        if w_totals[j] > max_w:
            max_w = w_totals[j]
            w_list = [j]
        elif w_totals[j] == max_w:
            w_list.append(j)

    for i in h_list:
        for j in w_list:
            if j not in overlap[i]:
                print(max_h + max_w)
                return
    print(max_h + max_w - 1) def resolve():
    H, W, M = map(int, input().split())
    pos = []
    for _ in range(M):
        pos.append(list(map(int, input().split())))

    h_totals = [0] * (H+1)
    w_totals = [0] * (W+1)
    overlap = [set() for _ in range(H+1)]

    for ph, pw in pos:
        h_totals[ph] += 1
        w_totals[pw] += 1
        overlap[ph].add(pw)

    max_h = -1
    max_w = -1
    h_list = []
    w_list = []
    for i in range(1, H+1):
        if h_totals[i] > max_h:
            max_h = h_totals[i]
            h_list = [i]
        elif h_totals[i] == max_h:
            h_list.append(i)
    for j in range(1, W+1):
        if w_totals[j] > max_w:
            max_w = w_totals[j]
            w_list = [j]
        elif w_totals[j] == max_w:
            w_list.append(j)

    for i in h_list:
        for j in w_list:
            if j not in overlap[i]:
                print(max_h + max_w)
                return
    print(max_h + max_w - 1) resolve
def resolve():
    H, W, M = map(int, input().split())
    pos = []
    for _ in range(M):
        pos.append(list(map(int, input().split())))

    h_totals = [0] * (H+1)
    w_totals = [0] * (W+1)
    overlap = [set() for _ in range(H+1)]

    for ph, pw in pos:
        h_totals[ph] += 1
        w_totals[pw] += 1
        overlap[ph].add(pw)

    max_h = -1
    max_w = -1
    h_list = []
    w_list = []
    for i in range(1, H+1):
        if h_totals[i] > max_h:
            max_h = h_totals[i]
            h_list = [i]
        elif h_totals[i] == max_h:
            h_list.append(i)
    for j in range(1, W+1):
        if w_totals[j] > max_w:
            max_w = w_totals[j]
            w_list = [j]
        elif w_totals[j] == max_w:
            w_list.append(j)

    for i in h_list:
        for j in w_list:
            if j not in overlap[i]:
                print(max_h + max_w)
                return
    print(max_h + max_w - 1)

if __name__ == "__main__":
    resolve()