def main():
    H, W, M = [int(s) for s in input().split()]
    cols = [0] * W
    rows = [0] * H
    bombs = set()
    for _ in range(M):
        x, y = [int(s)-1 for s in input().split()]
        bombs.add((x, y))
        cols[y] += 1
        rows[x] += 1

    sc = sorted([(c, i) for i, c in enumerate(cols)], reverse=True)
    sr = sorted([(c, i) for i, c in enumerate(rows)], reverse=True)
    best = 0
    for v1, c in sc:
        for v2, r in sr:
            if v1 + v2 <= best:
                break
            score = v1 + v2
            if (r, c) in bombs:
                score -= 1
            best = max(best, score)
    print(best)

main() def main():
    H, W, M = [int(s) for s in input().split()]
    cols = [0] * W
    rows = [0] * H
    bombs = set()
    for _ in range(M):
        x, y = [int(s)-1 for s in input().split()]
        bombs.add((x, y))
        cols[y] += 1
        rows[x] += 1

    sc = sorted([(c, i) for i, c in enumerate(cols)], reverse=True)
    sr = sorted([(c, i) for i, c in enumerate(rows)], reverse=True)
    best = 0
    for v1, c in sc:
        for v2, r in sr:
            if v1 + v2 <= best:
                break
            score = v1 + v2
            if (r, c) in bombs:
                score -= 1
            best = max(best, score)
    print(best) main int(s) for s in input().split() for s in input().split() s input().split() ().split () input split for s in input().split() int(s) int s H, W, M = [int(s) for s in input().split()] H [int(s) for s in input().split()] W M cols = [0] * W cols [0] * W [0] 0 W rows = [0] * H rows [0] * H [0] 0 H bombs = set() bombs set() set for _ in range(M):
        x, y = [int(s)-1 for s in input().split()]
        bombs.add((x, y))
        cols[y] += 1
        rows[x] += 1

     _ range(M) range M int(s)-1 for s in input().split() for s in input().split() s input().split() ().split () input split for s in input().split() int(s)-1 int(s) int s 1 x, y = [int(s)-1 for s in input().split()] x [int(s)-1 for s in input().split()] y bombs.add((x, y)) bombs.add bombs add (x, y) x y cols[y] += 1 cols[y] cols y 1 rows[x] += 1 rows[x] rows x 1 (c, i) for i, c in enumerate(cols) for i, c in enumerate(cols) i c enumerate(cols) enumerate cols for i, c in enumerate(cols) (c, i) c i sc = sorted([(c, i) for i, c in enumerate(cols)], reverse=True) sc sorted([(c, i) for i, c in enumerate(cols)], reverse=True) sorted [(c, i) for i, c in enumerate(cols)] reverse=True reverse True (c, i) for i, c in enumerate(rows) for i, c in enumerate(rows) i c enumerate(rows) enumerate rows for i, c in enumerate(rows) (c, i) c i sr = sorted([(c, i) for i, c in enumerate(rows)], reverse=True) sr sorted([(c, i) for i, c in enumerate(rows)], reverse=True) sorted [(c, i) for i, c in enumerate(rows)] reverse=True reverse True best = 0 best 0 for v1, c in sc:
        for v2, r in sr:
            if v1 + v2 <= best:
                break
            score = v1 + v2
            if (r, c) in bombs:
                score -= 1
            best = max(best, score)
     v1 c sc for v2, r in sr:
            if v1 + v2 <= best:
                break
            score = v1 + v2
            if (r, c) in bombs:
                score -= 1
            best = max(best, score)
     v2 r sr if v1 + v2 <= best:
                break
             v1 + v2 <= best v1 + v2 v1 v2 best break score = v1 + v2 score v1 + v2 v1 v2 if (r, c) in bombs:
                score -= 1
             (r, c) in bombs (r, c) r c bombs score -= 1 score 1 best = max(best, score) best max(best, score) max best score print(best) print best main() main def main():
    H, W, M = [int(s) for s in input().split()]
    cols = [0] * W
    rows = [0] * H
    bombs = set()
    for _ in range(M):
        x, y = [int(s)-1 for s in input().split()]
        bombs.add((x, y))
        cols[y] += 1
        rows[x] += 1

    sc = sorted([(c, i) for i, c in enumerate(cols)], reverse=True)
    sr = sorted([(c, i) for i, c in enumerate(rows)], reverse=True)
    best = 0
    for v1, c in sc:
        for v2, r in sr:
            if v1 + v2 <= best:
                break
            score = v1 + v2
            if (r, c) in bombs:
                score -= 1
            best = max(best, score)
    print(best) def main():
    H, W, M = [int(s) for s in input().split()]
    cols = [0] * W
    rows = [0] * H
    bombs = set()
    for _ in range(M):
        x, y = [int(s)-1 for s in input().split()]
        bombs.add((x, y))
        cols[y] += 1
        rows[x] += 1

    sc = sorted([(c, i) for i, c in enumerate(cols)], reverse=True)
    sr = sorted([(c, i) for i, c in enumerate(rows)], reverse=True)
    best = 0
    for v1, c in sc:
        for v2, r in sr:
            if v1 + v2 <= best:
                break
            score = v1 + v2
            if (r, c) in bombs:
                score -= 1
            best = max(best, score)
    print(best) main
def main():
    H, W, M = [int(s) for s in input().split()]
    cols = [0] * W
    rows = [0] * H
    bombs = set()
    for _ in range(M):
        x, y = [int(s)-1 for s in input().split()]
        bombs.add((x, y))
        cols[y] += 1
        rows[x] += 1

    sc = sorted([(c, i) for i, c in enumerate(cols)], reverse=True)
    sr = sorted([(c, i) for i, c in enumerate(rows)], reverse=True)
    best = 0
    for v1, c in sc:
        for v2, r in sr:
            if v1 + v2 <= best:
                break
            score = v1 + v2
            if (r, c) in bombs:
                score -= 1
            best = max(best, score)
    print(best)

main()