func readThreeInts(separator: String.Element = " ") -> (a: Int, b: Int, c: Int) {
    let ints = readLine()!.split(separator: separator).map { Int($0)! }
    return (a: ints[0], b: ints[1], c: ints[2])
}

func readTwoInts(separator: String.Element = " ") -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: separator).map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

func mainE() {
    let (H, W, M) = readThreeInts()

    let points: [(y: Int, x: Int)] = (0..<M).map { _ in readTwoInts() }

    var yCount: [Int] = .init(repeating: 0, count: H)
    var xCount: [Int] = .init(repeating: 0, count: W)

    // 集計
    for point in points {
        xCount[point.x - 1] += 1
        yCount[point.y - 1] += 1
    }

    let maxX = xCount.max()!
    let maxY = yCount.max()!

    let answer = maxX + maxY

    // 対象がない点の方が良い, 対象が存在しない点があれば-1しない
    var answerPoints: [(y: Int, x: Int)] = []
    for (indexX, elementX) in xCount.enumerated() {
        for (indexY, elementY) in yCount.enumerated() {
            if elementX == maxX && elementY == maxY {
                answerPoints.append((indexY + 1, indexX + 1))
            }
        }
    }

    var isDubbled = true
    answerPoints.forEach { (answerY, answerX) in
        if !points.contains(where: { (y, x) in y == answerY && x == answerX }) {
            isDubbled = false
        }
    }

    print(isDubbled ? answer - 1 : answer)
}
mainE()