import sys
input = sys.stdin.readline

def main():
    h, w, m = map(int, input().split())
    bomb_row = [0] * h
    bomb_col = [0] * w
    # 座標だけはsetで格納
    bomb_pos = set()
    # 爆弾情報を行と列ごとで格納
    for _ in range(m):
        r, c = [int(i) - 1 for i in input().split()]
        bomb_row[r] += 1
        bomb_col[c] += 1
        bomb_pos.add((r,c))

    bomb_row_max = max(bomb_row)
    bomb_col_max = max(bomb_col)

    row_index = [i for i, v in enumerate(bomb_row) if v == bomb_row_max]
    col_index = [i for i, v in enumerate(bomb_col) if v == bomb_col_max]
    ans = bomb_col_max + bomb_row_max
    for row in row_index:
        for col in col_index:
            if (row, col) not in bomb_pos:
                print(ans)
                return
    print(ans-1)
main() import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline def main():
    h, w, m = map(int, input().split())
    bomb_row = [0] * h
    bomb_col = [0] * w
    # 座標だけはsetで格納
    bomb_pos = set()
    # 爆弾情報を行と列ごとで格納
    for _ in range(m):
        r, c = [int(i) - 1 for i in input().split()]
        bomb_row[r] += 1
        bomb_col[c] += 1
        bomb_pos.add((r,c))

    bomb_row_max = max(bomb_row)
    bomb_col_max = max(bomb_col)

    row_index = [i for i, v in enumerate(bomb_row) if v == bomb_row_max]
    col_index = [i for i, v in enumerate(bomb_col) if v == bomb_col_max]
    ans = bomb_col_max + bomb_row_max
    for row in row_index:
        for col in col_index:
            if (row, col) not in bomb_pos:
                print(ans)
                return
    print(ans-1) main h, w, m = map(int, input().split()) h map(int, input().split()) map int input().split() ().split () input split w m bomb_row = [0] * h bomb_row [0] * h [0] 0 h bomb_col = [0] * w bomb_col [0] * w [0] 0 w bomb_pos = set() bomb_pos set() set for _ in range(m):
        r, c = [int(i) - 1 for i in input().split()]
        bomb_row[r] += 1
        bomb_col[c] += 1
        bomb_pos.add((r,c))

     _ range(m) range m int(i) - 1 for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) - 1 int(i) int i 1 r, c = [int(i) - 1 for i in input().split()] r [int(i) - 1 for i in input().split()] c bomb_row[r] += 1 bomb_row[r] bomb_row r 1 bomb_col[c] += 1 bomb_col[c] bomb_col c 1 bomb_pos.add((r,c)) bomb_pos.add bomb_pos add (r,c) r c bomb_row_max = max(bomb_row) bomb_row_max max(bomb_row) max bomb_row bomb_col_max = max(bomb_col) bomb_col_max max(bomb_col) max bomb_col i for i, v in enumerate(bomb_row) if v == bomb_row_max for i, v in enumerate(bomb_row) if v == bomb_row_max i v enumerate(bomb_row) enumerate bomb_row v == bomb_row_max v bomb_row_max if v == bomb_row_max i row_index = [i for i, v in enumerate(bomb_row) if v == bomb_row_max] row_index [i for i, v in enumerate(bomb_row) if v == bomb_row_max] i for i, v in enumerate(bomb_col) if v == bomb_col_max for i, v in enumerate(bomb_col) if v == bomb_col_max i v enumerate(bomb_col) enumerate bomb_col v == bomb_col_max v bomb_col_max if v == bomb_col_max i col_index = [i for i, v in enumerate(bomb_col) if v == bomb_col_max] col_index [i for i, v in enumerate(bomb_col) if v == bomb_col_max] ans = bomb_col_max + bomb_row_max ans bomb_col_max + bomb_row_max bomb_col_max bomb_row_max for row in row_index:
        for col in col_index:
            if (row, col) not in bomb_pos:
                print(ans)
                return
     row row_index for col in col_index:
            if (row, col) not in bomb_pos:
                print(ans)
                return
     col col_index if (row, col) not in bomb_pos:
                print(ans)
                return
     (row, col) not in bomb_pos (row, col) row col bomb_pos print(ans) print ans return print(ans-1) print ans-1 ans 1 main() main def main():
    h, w, m = map(int, input().split())
    bomb_row = [0] * h
    bomb_col = [0] * w
    # 座標だけはsetで格納
    bomb_pos = set()
    # 爆弾情報を行と列ごとで格納
    for _ in range(m):
        r, c = [int(i) - 1 for i in input().split()]
        bomb_row[r] += 1
        bomb_col[c] += 1
        bomb_pos.add((r,c))

    bomb_row_max = max(bomb_row)
    bomb_col_max = max(bomb_col)

    row_index = [i for i, v in enumerate(bomb_row) if v == bomb_row_max]
    col_index = [i for i, v in enumerate(bomb_col) if v == bomb_col_max]
    ans = bomb_col_max + bomb_row_max
    for row in row_index:
        for col in col_index:
            if (row, col) not in bomb_pos:
                print(ans)
                return
    print(ans-1) def main():
    h, w, m = map(int, input().split())
    bomb_row = [0] * h
    bomb_col = [0] * w
    # 座標だけはsetで格納
    bomb_pos = set()
    # 爆弾情報を行と列ごとで格納
    for _ in range(m):
        r, c = [int(i) - 1 for i in input().split()]
        bomb_row[r] += 1
        bomb_col[c] += 1
        bomb_pos.add((r,c))

    bomb_row_max = max(bomb_row)
    bomb_col_max = max(bomb_col)

    row_index = [i for i, v in enumerate(bomb_row) if v == bomb_row_max]
    col_index = [i for i, v in enumerate(bomb_col) if v == bomb_col_max]
    ans = bomb_col_max + bomb_row_max
    for row in row_index:
        for col in col_index:
            if (row, col) not in bomb_pos:
                print(ans)
                return
    print(ans-1) main input = sys.stdin.readline sys.stdin.readline input
import sys
input = sys.stdin.readline

def main():
    h, w, m = map(int, input().split())
    bomb_row = [0] * h
    bomb_col = [0] * w
    # 座標だけはsetで格納
    bomb_pos = set()
    # 爆弾情報を行と列ごとで格納
    for _ in range(m):
        r, c = [int(i) - 1 for i in input().split()]
        bomb_row[r] += 1
        bomb_col[c] += 1
        bomb_pos.add((r,c))

    bomb_row_max = max(bomb_row)
    bomb_col_max = max(bomb_col)

    row_index = [i for i, v in enumerate(bomb_row) if v == bomb_row_max]
    col_index = [i for i, v in enumerate(bomb_col) if v == bomb_col_max]
    ans = bomb_col_max + bomb_row_max
    for row in row_index:
        for col in col_index:
            if (row, col) not in bomb_pos:
                print(ans)
                return
    print(ans-1)
main()