def solve(h, w, m, hw_list):
    h_count = [0] * (h + 1)
    w_count = [0] * (w + 1)
    for h_, w_ in hw_list:
        h_count[h_] += 1
        w_count[w_] += 1

    h_max = max(h_count)
    w_max = max(w_count)
    res = h_max + w_max

    h_max_count = 0
    w_max_count = 0
    for i in range(h + 1):
        if h_count[i] == h_max:
            h_max_count += 1
    for j in range(w + 1):
        if w_count[j] == w_max:
            w_max_count += 1

    max_count = h_max_count * w_max_count
    max_count_cross = 0
    for h_, w_ in hw_list:
        if h_count[h_] == h_max and w_count[w_] == w_max:
            max_count_cross += 1

    if max_count_cross == max_count:
        return res - 1
    else:
        return res


def main():
    h, w, m = map(int, input().split())
    hw_list = []
    for _ in range(m):
        hw_list.append(list(map(int, input().split())))
    res = solve(h, w, m, hw_list)
    print(res)


def test():
    assert solve(2, 3, 3, [[2, 2], [1, 1], [1, 3]]) == 3
    assert solve(3, 3, 4, [[3, 3], [3, 1], [1, 1], [1, 2]]) == 3
    assert solve(5, 5, 10, [[2, 5], [4, 3], [2, 3], [5, 5], [2, 2], [5, 4], [5, 3], [5, 1], [3, 5], [1, 4]]) == 6


if __name__ == "__main__":
    test()
    main() def solve(h, w, m, hw_list):
    h_count = [0] * (h + 1)
    w_count = [0] * (w + 1)
    for h_, w_ in hw_list:
        h_count[h_] += 1
        w_count[w_] += 1

    h_max = max(h_count)
    w_max = max(w_count)
    res = h_max + w_max

    h_max_count = 0
    w_max_count = 0
    for i in range(h + 1):
        if h_count[i] == h_max:
            h_max_count += 1
    for j in range(w + 1):
        if w_count[j] == w_max:
            w_max_count += 1

    max_count = h_max_count * w_max_count
    max_count_cross = 0
    for h_, w_ in hw_list:
        if h_count[h_] == h_max and w_count[w_] == w_max:
            max_count_cross += 1

    if max_count_cross == max_count:
        return res - 1
    else:
        return res solve h_count = [0] * (h + 1) h_count [0] * (h + 1) [0] 0 h + 1 h 1 w_count = [0] * (w + 1) w_count [0] * (w + 1) [0] 0 w + 1 w 1 for h_, w_ in hw_list:
        h_count[h_] += 1
        w_count[w_] += 1

     h_ w_ hw_list h_count[h_] += 1 h_count[h_] h_count h_ 1 w_count[w_] += 1 w_count[w_] w_count w_ 1 h_max = max(h_count) h_max max(h_count) max h_count w_max = max(w_count) w_max max(w_count) max w_count res = h_max + w_max res h_max + w_max h_max w_max h_max_count = 0 h_max_count 0 w_max_count = 0 w_max_count 0 for i in range(h + 1):
        if h_count[i] == h_max:
            h_max_count += 1
     i range(h + 1) range h + 1 h 1 if h_count[i] == h_max:
            h_max_count += 1
     h_count[i] == h_max h_count[i] h_count i h_max h_max_count += 1 h_max_count 1 for j in range(w + 1):
        if w_count[j] == w_max:
            w_max_count += 1

     j range(w + 1) range w + 1 w 1 if w_count[j] == w_max:
            w_max_count += 1

     w_count[j] == w_max w_count[j] w_count j w_max w_max_count += 1 w_max_count 1 max_count = h_max_count * w_max_count max_count h_max_count * w_max_count h_max_count w_max_count max_count_cross = 0 max_count_cross 0 for h_, w_ in hw_list:
        if h_count[h_] == h_max and w_count[w_] == w_max:
            max_count_cross += 1

     h_ w_ hw_list if h_count[h_] == h_max and w_count[w_] == w_max:
            max_count_cross += 1

     h_count[h_] == h_max and w_count[w_] == w_max h_count[h_] == h_max h_count[h_] h_count h_ h_max w_count[w_] == w_max w_count[w_] w_count w_ w_max max_count_cross += 1 max_count_cross 1 if max_count_cross == max_count:
        return res - 1
    else:
        return res max_count_cross == max_count max_count_cross max_count return res - 1 res - 1 res 1 return res res h h w w m m hw_list hw_list def main():
    h, w, m = map(int, input().split())
    hw_list = []
    for _ in range(m):
        hw_list.append(list(map(int, input().split())))
    res = solve(h, w, m, hw_list)
    print(res) main h, w, m = map(int, input().split()) h map(int, input().split()) map int input().split() ().split () input split w m hw_list = [] hw_list [] for _ in range(m):
        hw_list.append(list(map(int, input().split())))
     _ range(m) range m hw_list.append(list(map(int, input().split()))) hw_list.append hw_list append list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split res = solve(h, w, m, hw_list) res solve(h, w, m, hw_list) solve h w m hw_list print(res) print res def test():
    assert solve(2, 3, 3, [[2, 2], [1, 1], [1, 3]]) == 3
    assert solve(3, 3, 4, [[3, 3], [3, 1], [1, 1], [1, 2]]) == 3
    assert solve(5, 5, 10, [[2, 5], [4, 3], [2, 3], [5, 5], [2, 2], [5, 4], [5, 3], [5, 1], [3, 5], [1, 4]]) == 6 test assert solve(2, 3, 3, [[2, 2], [1, 1], [1, 3]]) == 3 solve(2, 3, 3, [[2, 2], [1, 1], [1, 3]]) == 3 solve(2, 3, 3, [[2, 2], [1, 1], [1, 3]]) solve 2 3 3 [[2, 2], [1, 1], [1, 3]] [2, 2] 2 2 [1, 1] 1 1 [1, 3] 1 3 3 assert solve(3, 3, 4, [[3, 3], [3, 1], [1, 1], [1, 2]]) == 3 solve(3, 3, 4, [[3, 3], [3, 1], [1, 1], [1, 2]]) == 3 solve(3, 3, 4, [[3, 3], [3, 1], [1, 1], [1, 2]]) solve 3 3 4 [[3, 3], [3, 1], [1, 1], [1, 2]] [3, 3] 3 3 [3, 1] 3 1 [1, 1] 1 1 [1, 2] 1 2 3 assert solve(5, 5, 10, [[2, 5], [4, 3], [2, 3], [5, 5], [2, 2], [5, 4], [5, 3], [5, 1], [3, 5], [1, 4]]) == 6 solve(5, 5, 10, [[2, 5], [4, 3], [2, 3], [5, 5], [2, 2], [5, 4], [5, 3], [5, 1], [3, 5], [1, 4]]) == 6 solve(5, 5, 10, [[2, 5], [4, 3], [2, 3], [5, 5], [2, 2], [5, 4], [5, 3], [5, 1], [3, 5], [1, 4]]) solve 5 5 10 [[2, 5], [4, 3], [2, 3], [5, 5], [2, 2], [5, 4], [5, 3], [5, 1], [3, 5], [1, 4]] [2, 5] 2 5 [4, 3] 4 3 [2, 3] 2 3 [5, 5] 5 5 [2, 2] 2 2 [5, 4] 5 4 [5, 3] 5 3 [5, 1] 5 1 [3, 5] 3 5 [1, 4] 1 4 6 if __name__ == "__main__":
    test()
    main() __name__ == "__main__" __name__ "__main__" test() test main() main def solve(h, w, m, hw_list):
    h_count = [0] * (h + 1)
    w_count = [0] * (w + 1)
    for h_, w_ in hw_list:
        h_count[h_] += 1
        w_count[w_] += 1

    h_max = max(h_count)
    w_max = max(w_count)
    res = h_max + w_max

    h_max_count = 0
    w_max_count = 0
    for i in range(h + 1):
        if h_count[i] == h_max:
            h_max_count += 1
    for j in range(w + 1):
        if w_count[j] == w_max:
            w_max_count += 1

    max_count = h_max_count * w_max_count
    max_count_cross = 0
    for h_, w_ in hw_list:
        if h_count[h_] == h_max and w_count[w_] == w_max:
            max_count_cross += 1

    if max_count_cross == max_count:
        return res - 1
    else:
        return res def solve(h, w, m, hw_list):
    h_count = [0] * (h + 1)
    w_count = [0] * (w + 1)
    for h_, w_ in hw_list:
        h_count[h_] += 1
        w_count[w_] += 1

    h_max = max(h_count)
    w_max = max(w_count)
    res = h_max + w_max

    h_max_count = 0
    w_max_count = 0
    for i in range(h + 1):
        if h_count[i] == h_max:
            h_max_count += 1
    for j in range(w + 1):
        if w_count[j] == w_max:
            w_max_count += 1

    max_count = h_max_count * w_max_count
    max_count_cross = 0
    for h_, w_ in hw_list:
        if h_count[h_] == h_max and w_count[w_] == w_max:
            max_count_cross += 1

    if max_count_cross == max_count:
        return res - 1
    else:
        return res solve def main():
    h, w, m = map(int, input().split())
    hw_list = []
    for _ in range(m):
        hw_list.append(list(map(int, input().split())))
    res = solve(h, w, m, hw_list)
    print(res) def main():
    h, w, m = map(int, input().split())
    hw_list = []
    for _ in range(m):
        hw_list.append(list(map(int, input().split())))
    res = solve(h, w, m, hw_list)
    print(res) main def test():
    assert solve(2, 3, 3, [[2, 2], [1, 1], [1, 3]]) == 3
    assert solve(3, 3, 4, [[3, 3], [3, 1], [1, 1], [1, 2]]) == 3
    assert solve(5, 5, 10, [[2, 5], [4, 3], [2, 3], [5, 5], [2, 2], [5, 4], [5, 3], [5, 1], [3, 5], [1, 4]]) == 6 def test():
    assert solve(2, 3, 3, [[2, 2], [1, 1], [1, 3]]) == 3
    assert solve(3, 3, 4, [[3, 3], [3, 1], [1, 1], [1, 2]]) == 3
    assert solve(5, 5, 10, [[2, 5], [4, 3], [2, 3], [5, 5], [2, 2], [5, 4], [5, 3], [5, 1], [3, 5], [1, 4]]) == 6 test
def solve(h, w, m, hw_list):
    h_count = [0] * (h + 1)
    w_count = [0] * (w + 1)
    for h_, w_ in hw_list:
        h_count[h_] += 1
        w_count[w_] += 1

    h_max = max(h_count)
    w_max = max(w_count)
    res = h_max + w_max

    h_max_count = 0
    w_max_count = 0
    for i in range(h + 1):
        if h_count[i] == h_max:
            h_max_count += 1
    for j in range(w + 1):
        if w_count[j] == w_max:
            w_max_count += 1

    max_count = h_max_count * w_max_count
    max_count_cross = 0
    for h_, w_ in hw_list:
        if h_count[h_] == h_max and w_count[w_] == w_max:
            max_count_cross += 1

    if max_count_cross == max_count:
        return res - 1
    else:
        return res


def main():
    h, w, m = map(int, input().split())
    hw_list = []
    for _ in range(m):
        hw_list.append(list(map(int, input().split())))
    res = solve(h, w, m, hw_list)
    print(res)


def test():
    assert solve(2, 3, 3, [[2, 2], [1, 1], [1, 3]]) == 3
    assert solve(3, 3, 4, [[3, 3], [3, 1], [1, 1], [1, 2]]) == 3
    assert solve(5, 5, 10, [[2, 5], [4, 3], [2, 3], [5, 5], [2, 2], [5, 4], [5, 3], [5, 1], [3, 5], [1, 4]]) == 6


if __name__ == "__main__":
    test()
    main()
