def main():
    h, w, m, *BOM = map(int, open(0).read().split())
    row = [0] * h
    col = [0] * w
    for i, j in zip(BOM[::2], BOM[1::2]):
        i -= 1
        j -= 1
        row[i] += 1
        col[j] += 1

    p, q = max(row), max(col)
    rr = sum(1 for i in range(h) if row[i] == p)
    rl = sum(1 for i in range(w) if col[i] == q)

    cnd = rr * rl

    for i, j in zip(BOM[::2], BOM[1::2]):
        i -= 1
        j -= 1
        if (row[i], col[j]) == (p, q):
            cnd -= 1

    if cnd > 0:
        ans = p + q
    else:
        ans = p + q - 1

    print(ans)


if __name__ == '__main__':
    main() def main():
    h, w, m, *BOM = map(int, open(0).read().split())
    row = [0] * h
    col = [0] * w
    for i, j in zip(BOM[::2], BOM[1::2]):
        i -= 1
        j -= 1
        row[i] += 1
        col[j] += 1

    p, q = max(row), max(col)
    rr = sum(1 for i in range(h) if row[i] == p)
    rl = sum(1 for i in range(w) if col[i] == q)

    cnd = rr * rl

    for i, j in zip(BOM[::2], BOM[1::2]):
        i -= 1
        j -= 1
        if (row[i], col[j]) == (p, q):
            cnd -= 1

    if cnd > 0:
        ans = p + q
    else:
        ans = p + q - 1

    print(ans) main h, w, m, *BOM = map(int, open(0).read().split()) h map(int, open(0).read().split()) map int open(0).read().split() (0).read().split (0).read() (0).read (0) open 0 read split w m *BOM BOM row = [0] * h row [0] * h [0] 0 h col = [0] * w col [0] * w [0] 0 w for i, j in zip(BOM[::2], BOM[1::2]):
        i -= 1
        j -= 1
        row[i] += 1
        col[j] += 1

     i j zip(BOM[::2], BOM[1::2]) zip BOM[::2] BOM ::2 2 BOM[1::2] BOM 1::2 1 2 i -= 1 i 1 j -= 1 j 1 row[i] += 1 row[i] row i 1 col[j] += 1 col[j] col j 1 p, q = max(row), max(col) p max(row) max row q max(col) max col rr = sum(1 for i in range(h) if row[i] == p) rr sum(1 for i in range(h) if row[i] == p) sum 1 rl = sum(1 for i in range(w) if col[i] == q) rl sum(1 for i in range(w) if col[i] == q) sum 1 cnd = rr * rl cnd rr * rl rr rl for i, j in zip(BOM[::2], BOM[1::2]):
        i -= 1
        j -= 1
        if (row[i], col[j]) == (p, q):
            cnd -= 1

     i j zip(BOM[::2], BOM[1::2]) zip BOM[::2] BOM ::2 2 BOM[1::2] BOM 1::2 1 2 i -= 1 i 1 j -= 1 j 1 if (row[i], col[j]) == (p, q):
            cnd -= 1

     (row[i], col[j]) == (p, q) (row[i], col[j]) row[i] row i col[j] col j (p, q) p q cnd -= 1 cnd 1 if cnd > 0:
        ans = p + q
    else:
        ans = p + q - 1

     cnd > 0 cnd 0 ans = p + q ans p + q p q ans = p + q - 1 ans p + q - 1 p + q p q 1 print(ans) print ans if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    h, w, m, *BOM = map(int, open(0).read().split())
    row = [0] * h
    col = [0] * w
    for i, j in zip(BOM[::2], BOM[1::2]):
        i -= 1
        j -= 1
        row[i] += 1
        col[j] += 1

    p, q = max(row), max(col)
    rr = sum(1 for i in range(h) if row[i] == p)
    rl = sum(1 for i in range(w) if col[i] == q)

    cnd = rr * rl

    for i, j in zip(BOM[::2], BOM[1::2]):
        i -= 1
        j -= 1
        if (row[i], col[j]) == (p, q):
            cnd -= 1

    if cnd > 0:
        ans = p + q
    else:
        ans = p + q - 1

    print(ans) def main():
    h, w, m, *BOM = map(int, open(0).read().split())
    row = [0] * h
    col = [0] * w
    for i, j in zip(BOM[::2], BOM[1::2]):
        i -= 1
        j -= 1
        row[i] += 1
        col[j] += 1

    p, q = max(row), max(col)
    rr = sum(1 for i in range(h) if row[i] == p)
    rl = sum(1 for i in range(w) if col[i] == q)

    cnd = rr * rl

    for i, j in zip(BOM[::2], BOM[1::2]):
        i -= 1
        j -= 1
        if (row[i], col[j]) == (p, q):
            cnd -= 1

    if cnd > 0:
        ans = p + q
    else:
        ans = p + q - 1

    print(ans) main
def main():
    h, w, m, *BOM = map(int, open(0).read().split())
    row = [0] * h
    col = [0] * w
    for i, j in zip(BOM[::2], BOM[1::2]):
        i -= 1
        j -= 1
        row[i] += 1
        col[j] += 1

    p, q = max(row), max(col)
    rr = sum(1 for i in range(h) if row[i] == p)
    rl = sum(1 for i in range(w) if col[i] == q)

    cnd = rr * rl

    for i, j in zip(BOM[::2], BOM[1::2]):
        i -= 1
        j -= 1
        if (row[i], col[j]) == (p, q):
            cnd -= 1

    if cnd > 0:
        ans = p + q
    else:
        ans = p + q - 1

    print(ans)


if __name__ == '__main__':
    main()
