def resolve():
    '''
    code here
    '''
    H, W, M = [int(item) for item in input().split()]
    targets = [[int(item) -1 for item in input().split()] for _ in range(M)]

    col = [0 for _ in range(H)]
    row = [0 for _ in range(W)]

    bomb_set = set()
    # 配列で要素を作ると要素数が$10^8$超える場合、setで要素の座標を持っておく


    for i,j in targets:
        col[i] += 1
        row[j] += 1
        bomb_set.add((i,j))

    max_col = max(col)
    max_row = max(row)
    max_col_index = []
    max_row_index = []

    for i in range(H):
        if col[i] == max_col:
            max_col_index.append(i)

    for i in range(W):
        if row[i] == max_row:
            max_row_index.append(i)

    res = 0
    for item in max_col_index:
        for jtem in max_row_index:
            if (item,jtem) not in bomb_set:
                res =max_col + max_row
                break
        else:
            res = max(res, max_col + max_row -1 )
    print(res)

if __name__ == "__main__":
    resolve() def resolve():
    '''
    code here
    '''
    H, W, M = [int(item) for item in input().split()]
    targets = [[int(item) -1 for item in input().split()] for _ in range(M)]

    col = [0 for _ in range(H)]
    row = [0 for _ in range(W)]

    bomb_set = set()
    # 配列で要素を作ると要素数が$10^8$超える場合、setで要素の座標を持っておく


    for i,j in targets:
        col[i] += 1
        row[j] += 1
        bomb_set.add((i,j))

    max_col = max(col)
    max_row = max(row)
    max_col_index = []
    max_row_index = []

    for i in range(H):
        if col[i] == max_col:
            max_col_index.append(i)

    for i in range(W):
        if row[i] == max_row:
            max_row_index.append(i)

    res = 0
    for item in max_col_index:
        for jtem in max_row_index:
            if (item,jtem) not in bomb_set:
                res =max_col + max_row
                break
        else:
            res = max(res, max_col + max_row -1 )
    print(res) resolve '''
    code here
    ''' int(item) for item in input().split() for item in input().split() item input().split() ().split () input split for item in input().split() int(item) int item H, W, M = [int(item) for item in input().split()] H [int(item) for item in input().split()] W M [int(item) -1 for item in input().split()] for _ in range(M) for _ in range(M) _ range(M) range M for _ in range(M) [int(item) -1 for item in input().split()] targets = [[int(item) -1 for item in input().split()] for _ in range(M)] targets [[int(item) -1 for item in input().split()] for _ in range(M)] 0 for _ in range(H) for _ in range(H) _ range(H) range H for _ in range(H) 0 col = [0 for _ in range(H)] col [0 for _ in range(H)] 0 for _ in range(W) for _ in range(W) _ range(W) range W for _ in range(W) 0 row = [0 for _ in range(W)] row [0 for _ in range(W)] bomb_set = set() bomb_set set() set for i,j in targets:
        col[i] += 1
        row[j] += 1
        bomb_set.add((i,j))

     i j targets col[i] += 1 col[i] col i 1 row[j] += 1 row[j] row j 1 bomb_set.add((i,j)) bomb_set.add bomb_set add (i,j) i j max_col = max(col) max_col max(col) max col max_row = max(row) max_row max(row) max row max_col_index = [] max_col_index [] max_row_index = [] max_row_index [] for i in range(H):
        if col[i] == max_col:
            max_col_index.append(i)

     i range(H) range H if col[i] == max_col:
            max_col_index.append(i)

     col[i] == max_col col[i] col i max_col max_col_index.append(i) max_col_index.append max_col_index append i for i in range(W):
        if row[i] == max_row:
            max_row_index.append(i)

     i range(W) range W if row[i] == max_row:
            max_row_index.append(i)

     row[i] == max_row row[i] row i max_row max_row_index.append(i) max_row_index.append max_row_index append i res = 0 res 0 for item in max_col_index:
        for jtem in max_row_index:
            if (item,jtem) not in bomb_set:
                res =max_col + max_row
                break
        else:
            res = max(res, max_col + max_row -1 )
     item max_col_index for jtem in max_row_index:
            if (item,jtem) not in bomb_set:
                res =max_col + max_row
                break
        else:
            res = max(res, max_col + max_row -1 )
     jtem max_row_index if (item,jtem) not in bomb_set:
                res =max_col + max_row
                break
         (item,jtem) not in bomb_set (item,jtem) item jtem bomb_set res =max_col + max_row res max_col + max_row max_col max_row break res = max(res, max_col + max_row -1 ) res max(res, max_col + max_row -1 ) max res max_col + max_row -1 max_col + max_row max_col max_row 1 print(res) print res if __name__ == "__main__":
    resolve() __name__ == "__main__" __name__ "__main__" resolve() resolve def resolve():
    '''
    code here
    '''
    H, W, M = [int(item) for item in input().split()]
    targets = [[int(item) -1 for item in input().split()] for _ in range(M)]

    col = [0 for _ in range(H)]
    row = [0 for _ in range(W)]

    bomb_set = set()
    # 配列で要素を作ると要素数が$10^8$超える場合、setで要素の座標を持っておく


    for i,j in targets:
        col[i] += 1
        row[j] += 1
        bomb_set.add((i,j))

    max_col = max(col)
    max_row = max(row)
    max_col_index = []
    max_row_index = []

    for i in range(H):
        if col[i] == max_col:
            max_col_index.append(i)

    for i in range(W):
        if row[i] == max_row:
            max_row_index.append(i)

    res = 0
    for item in max_col_index:
        for jtem in max_row_index:
            if (item,jtem) not in bomb_set:
                res =max_col + max_row
                break
        else:
            res = max(res, max_col + max_row -1 )
    print(res) def resolve():
    '''
    code here
    '''
    H, W, M = [int(item) for item in input().split()]
    targets = [[int(item) -1 for item in input().split()] for _ in range(M)]

    col = [0 for _ in range(H)]
    row = [0 for _ in range(W)]

    bomb_set = set()
    # 配列で要素を作ると要素数が$10^8$超える場合、setで要素の座標を持っておく


    for i,j in targets:
        col[i] += 1
        row[j] += 1
        bomb_set.add((i,j))

    max_col = max(col)
    max_row = max(row)
    max_col_index = []
    max_row_index = []

    for i in range(H):
        if col[i] == max_col:
            max_col_index.append(i)

    for i in range(W):
        if row[i] == max_row:
            max_row_index.append(i)

    res = 0
    for item in max_col_index:
        for jtem in max_row_index:
            if (item,jtem) not in bomb_set:
                res =max_col + max_row
                break
        else:
            res = max(res, max_col + max_row -1 )
    print(res) resolve
def resolve():
    '''
    code here
    '''
    H, W, M = [int(item) for item in input().split()]
    targets = [[int(item) -1 for item in input().split()] for _ in range(M)]

    col = [0 for _ in range(H)]
    row = [0 for _ in range(W)]

    bomb_set = set()
    # 配列で要素を作ると要素数が$10^8$超える場合、setで要素の座標を持っておく


    for i,j in targets:
        col[i] += 1
        row[j] += 1
        bomb_set.add((i,j))

    max_col = max(col)
    max_row = max(row)
    max_col_index = []
    max_row_index = []

    for i in range(H):
        if col[i] == max_col:
            max_col_index.append(i)

    for i in range(W):
        if row[i] == max_row:
            max_row_index.append(i)

    res = 0
    for item in max_col_index:
        for jtem in max_row_index:
            if (item,jtem) not in bomb_set:
                res =max_col + max_row
                break
        else:
            res = max(res, max_col + max_row -1 )
    print(res)

if __name__ == "__main__":
    resolve()
