from bisect import bisect_left
def main():
    h, w, m = map(int, input().split())
    bombs = set()
    cnt_row, cnt_col = [0]*(h+1), [0]*(w+1)
    for _ in range(m):
        y, x = map(int, input().split())
        cnt_row[y] += 1
        cnt_col[x] += 1
        bombs.add((y, x))
    max_cnt_row = max(cnt_row)
    max_cnt_col = max(cnt_col)
    idx_row = []
    idx_col = []
    for i in range(h+1):
        if cnt_row[i] == max_cnt_row:
            idx_row.append(i)
    for j in range(w+1):
        if cnt_col[j] == max_cnt_col:
            idx_col.append(j)
    ans = max_cnt_row + max_cnt_col - 1
    for i in idx_row:
        for j in idx_col:
            if not (i, j) in bombs:
                ans = max_cnt_row + max_cnt_col
                break
    print(ans)

if __name__ == "__main__":
    main() from bisect import bisect_left def main():
    h, w, m = map(int, input().split())
    bombs = set()
    cnt_row, cnt_col = [0]*(h+1), [0]*(w+1)
    for _ in range(m):
        y, x = map(int, input().split())
        cnt_row[y] += 1
        cnt_col[x] += 1
        bombs.add((y, x))
    max_cnt_row = max(cnt_row)
    max_cnt_col = max(cnt_col)
    idx_row = []
    idx_col = []
    for i in range(h+1):
        if cnt_row[i] == max_cnt_row:
            idx_row.append(i)
    for j in range(w+1):
        if cnt_col[j] == max_cnt_col:
            idx_col.append(j)
    ans = max_cnt_row + max_cnt_col - 1
    for i in idx_row:
        for j in idx_col:
            if not (i, j) in bombs:
                ans = max_cnt_row + max_cnt_col
                break
    print(ans) main h, w, m = map(int, input().split()) h map(int, input().split()) map int input().split() ().split () input split w m bombs = set() bombs set() set cnt_row, cnt_col = [0]*(h+1), [0]*(w+1) cnt_row [0]*(h+1) [0] 0 h+1 h 1 cnt_col [0]*(w+1) [0] 0 w+1 w 1 for _ in range(m):
        y, x = map(int, input().split())
        cnt_row[y] += 1
        cnt_col[x] += 1
        bombs.add((y, x))
     _ range(m) range m y, x = map(int, input().split()) y map(int, input().split()) map int input().split() ().split () input split x cnt_row[y] += 1 cnt_row[y] cnt_row y 1 cnt_col[x] += 1 cnt_col[x] cnt_col x 1 bombs.add((y, x)) bombs.add bombs add (y, x) y x max_cnt_row = max(cnt_row) max_cnt_row max(cnt_row) max cnt_row max_cnt_col = max(cnt_col) max_cnt_col max(cnt_col) max cnt_col idx_row = [] idx_row [] idx_col = [] idx_col [] for i in range(h+1):
        if cnt_row[i] == max_cnt_row:
            idx_row.append(i)
     i range(h+1) range h+1 h 1 if cnt_row[i] == max_cnt_row:
            idx_row.append(i)
     cnt_row[i] == max_cnt_row cnt_row[i] cnt_row i max_cnt_row idx_row.append(i) idx_row.append idx_row append i for j in range(w+1):
        if cnt_col[j] == max_cnt_col:
            idx_col.append(j)
     j range(w+1) range w+1 w 1 if cnt_col[j] == max_cnt_col:
            idx_col.append(j)
     cnt_col[j] == max_cnt_col cnt_col[j] cnt_col j max_cnt_col idx_col.append(j) idx_col.append idx_col append j ans = max_cnt_row + max_cnt_col - 1 ans max_cnt_row + max_cnt_col - 1 max_cnt_row + max_cnt_col max_cnt_row max_cnt_col 1 for i in idx_row:
        for j in idx_col:
            if not (i, j) in bombs:
                ans = max_cnt_row + max_cnt_col
                break
     i idx_row for j in idx_col:
            if not (i, j) in bombs:
                ans = max_cnt_row + max_cnt_col
                break
     j idx_col if not (i, j) in bombs:
                ans = max_cnt_row + max_cnt_col
                break
     not (i, j) in bombs (i, j) in bombs (i, j) i j bombs ans = max_cnt_row + max_cnt_col ans max_cnt_row + max_cnt_col max_cnt_row max_cnt_col break print(ans) print ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    h, w, m = map(int, input().split())
    bombs = set()
    cnt_row, cnt_col = [0]*(h+1), [0]*(w+1)
    for _ in range(m):
        y, x = map(int, input().split())
        cnt_row[y] += 1
        cnt_col[x] += 1
        bombs.add((y, x))
    max_cnt_row = max(cnt_row)
    max_cnt_col = max(cnt_col)
    idx_row = []
    idx_col = []
    for i in range(h+1):
        if cnt_row[i] == max_cnt_row:
            idx_row.append(i)
    for j in range(w+1):
        if cnt_col[j] == max_cnt_col:
            idx_col.append(j)
    ans = max_cnt_row + max_cnt_col - 1
    for i in idx_row:
        for j in idx_col:
            if not (i, j) in bombs:
                ans = max_cnt_row + max_cnt_col
                break
    print(ans) def main():
    h, w, m = map(int, input().split())
    bombs = set()
    cnt_row, cnt_col = [0]*(h+1), [0]*(w+1)
    for _ in range(m):
        y, x = map(int, input().split())
        cnt_row[y] += 1
        cnt_col[x] += 1
        bombs.add((y, x))
    max_cnt_row = max(cnt_row)
    max_cnt_col = max(cnt_col)
    idx_row = []
    idx_col = []
    for i in range(h+1):
        if cnt_row[i] == max_cnt_row:
            idx_row.append(i)
    for j in range(w+1):
        if cnt_col[j] == max_cnt_col:
            idx_col.append(j)
    ans = max_cnt_row + max_cnt_col - 1
    for i in idx_row:
        for j in idx_col:
            if not (i, j) in bombs:
                ans = max_cnt_row + max_cnt_col
                break
    print(ans) main
from bisect import bisect_left
def main():
    h, w, m = map(int, input().split())
    bombs = set()
    cnt_row, cnt_col = [0]*(h+1), [0]*(w+1)
    for _ in range(m):
        y, x = map(int, input().split())
        cnt_row[y] += 1
        cnt_col[x] += 1
        bombs.add((y, x))
    max_cnt_row = max(cnt_row)
    max_cnt_col = max(cnt_col)
    idx_row = []
    idx_col = []
    for i in range(h+1):
        if cnt_row[i] == max_cnt_row:
            idx_row.append(i)
    for j in range(w+1):
        if cnt_col[j] == max_cnt_col:
            idx_col.append(j)
    ans = max_cnt_row + max_cnt_col - 1
    for i in idx_row:
        for j in idx_col:
            if not (i, j) in bombs:
                ans = max_cnt_row + max_cnt_col
                break
    print(ans)

if __name__ == "__main__":
    main()