
Imports System.Console
Module Module1
    Dim ans As Int64
    Dim max As Int64
    Dim n, k, x, t As Int64
    Sub Main()
        Dim s() As String = ReadLine.Split
        Dim h, w As Integer
        Dim m As Integer
        h = s(0)
        w = s(1)
        m = s(2)
        Dim field(w, h) As Boolean
        Dim numw(h) As Int64
        Dim numh(w) As Int64
        For i = 1 To m
            s = ReadLine().Split
            field(s(1), s(0)) = True
            numw(s(0)) += 1
            numh(s(1)) += 1
        Next
        Dim maxindw, maxindh As Integer
        Dim maxws(), maxhs() As Integer
        For i = 1 To w
            If numh(i) > numh(maxindh) Then
                maxindh = i
            End If
        Next
        For i = 1 To w
            If numh(i) = numh(maxindh) Then
                Add(maxhs, i)
            End If
        Next
        For i = 1 To h
            If numw(i) > numw(maxindw) Then
                maxindw = i
            End If
        Next
        For i = 1 To h
            If numw(i) = numw(maxindw) Then
                Add(maxws, i)
            End If
        Next
        Dim ii As Integer
        Dim found As Boolean = False
        For i = 0 To maxhs.Length - 1
            'If found = True Then
            '    Exit For
            'End If
            For ii = 0 To maxws.Length - 1
                If field(maxhs(i), maxws(ii)) = False Then
                    found = True
                    'Exit For
                End If
            Next
        Next
        ans = numw(maxws(0)) + numh(maxhs(0))
        If found = False Then
            ans -= 1
        End If
        WriteLine(ans)
        ReadLine()
    End Sub
    Sub Add(ByRef arr() As Integer, ByVal num As Integer)
        If arr Is Nothing Then
            ReDim arr(0)
            arr(0) = num
        Else
            ReDim Preserve arr(arr.Length)
            arr(arr.Length - 1) = num
        End If
    End Sub
End Module
